From 2ec4f7d0da76a5d00b931a8eb05be5f68c2bf363 Mon Sep 17 00:00:00 2001 From: Fenny <25108519+Fenny@users.noreply.github.com> Date: Sat, 26 Sep 2020 11:13:11 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=A6=20introduce=20cache=20mw?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Tom --- middleware/cache/cache.go | 15 ++------------- middleware/cache/cache_test.go | 4 ++++ 2 files changed, 6 insertions(+), 13 deletions(-) create mode 100644 middleware/cache/cache_test.go diff --git a/middleware/cache/cache.go b/middleware/cache/cache.go index 91bd4985..647a3d4b 100644 --- a/middleware/cache/cache.go +++ b/middleware/cache/cache.go @@ -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 } diff --git a/middleware/cache/cache_test.go b/middleware/cache/cache_test.go new file mode 100644 index 00000000..17bcf42b --- /dev/null +++ b/middleware/cache/cache_test.go @@ -0,0 +1,4 @@ +// Special thanks to @codemicro for moving this to fiber core +// Original middleware: github.com/codemicro/fiber-cache +package cache +