mirror of
https://github.com/gofiber/fiber.git
synced 2025-02-23 15:23:58 +00:00
commit
fbf03afa43
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
@ -1 +1,4 @@
|
||||
* @gofiber/maintainers
|
||||
|
||||
middleware/filesystem/* @arsmn
|
||||
middleware/cache/* @codemicro
|
2
middleware/cache/README.md
vendored
2
middleware/cache/README.md
vendored
@ -1,5 +1,5 @@
|
||||
# Cache
|
||||
Cache middleware for [Fiber](https://github.com/gofiber/fiber) designed to intercept responses and cache them. This middleware will cache the `Body`, `Content-Type` and `StatusCode` using the `c.Path()` as unique identifier. Special thanks to [@codemicro](github.com/codemicro/fiber-cache).
|
||||
Cache middleware for [Fiber](https://github.com/gofiber/fiber) designed to intercept responses and cache them. This middleware will cache the `Body`, `Content-Type` and `StatusCode` using the `c.Path()` as unique identifier. Special thanks to [@codemicro](github.com/codemicro/fiber-cache) for creating this middleware for Fiber core!
|
||||
|
||||
### Table of Contents
|
||||
- [Signatures](#signatures)
|
||||
|
15
middleware/cache/cache.go
vendored
15
middleware/cache/cache.go
vendored
@ -1,4 +1,5 @@
|
||||
// Special thanks to @codemicro for helping with this middleware: github.com/codemicro/fiber-cache
|
||||
// Special thanks to @codemicro for moving this to fiber core
|
||||
// Original middleware: github.com/codemicro/fiber-cache
|
||||
package cache
|
||||
|
||||
import (
|
||||
@ -19,14 +20,6 @@ type Config struct {
|
||||
//
|
||||
// Optional. Default: 5 * time.Minute
|
||||
Expiration time.Duration
|
||||
|
||||
// // Hydrate is run before the response is returned to the client.
|
||||
// // Because this middleware is backend-agnostic, it makes no assumptions
|
||||
// // about what you want to do with cached response other than caching the statuscode,
|
||||
// // content-type and response body. Hydrate allows you to alter the cached response.
|
||||
// //
|
||||
// // Optional. Default: nil
|
||||
// Hydrate fiber.Handler
|
||||
}
|
||||
|
||||
// ConfigDefault is the default config
|
||||
@ -117,10 +110,6 @@ func New(config ...Config) fiber.Handler {
|
||||
c.Response().SetBodyRaw(resp.body)
|
||||
c.Response().SetStatusCode(resp.statusCode)
|
||||
c.Response().Header.SetContentTypeBytes(resp.contentType)
|
||||
// // Hydrate response if defined
|
||||
// if cfg.Hydrate != nil {
|
||||
// return cfg.Hydrate(c)
|
||||
// }
|
||||
return nil
|
||||
}
|
||||
|
||||
|
4
middleware/cache/cache_test.go
vendored
Normal file
4
middleware/cache/cache_test.go
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
// Special thanks to @codemicro for moving this to fiber core
|
||||
// Original middleware: github.com/codemicro/fiber-cache
|
||||
package cache
|
||||
|
Loading…
x
Reference in New Issue
Block a user