From 2a7001a734ed9c321f4a389f6d99216b0a3d0795 Mon Sep 17 00:00:00 2001 From: fenny <25108519+Fenny@users.noreply.github.com> Date: Wed, 27 May 2020 22:42:38 +0200 Subject: [PATCH] Update main.go --- main.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index a40c548..b49d64a 100644 --- a/main.go +++ b/main.go @@ -34,6 +34,7 @@ func FiberHandler(h func(*fiber.Ctx)) http.Handler { // FiberHandlerFunc wraps fiber handler to net/http handler func func FiberHandlerFunc(h func(*fiber.Ctx)) http.HandlerFunc { + app := fiber.New() return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { // New fasthttp request var req fasthttp.Request @@ -65,8 +66,7 @@ func FiberHandlerFunc(h func(*fiber.Ctx)) http.HandlerFunc { var fctx fasthttp.RequestCtx fctx.Init(&req, remoteAddr, nil) // New fiber Ctx - ctx := fiber.AcquireCtx(&fctx) - defer fiber.ReleaseCtx(ctx) + ctx := app.AcquireCtx(&fctx) // Execute fiber Ctx h(ctx) @@ -78,5 +78,6 @@ func FiberHandlerFunc(h func(*fiber.Ctx)) http.HandlerFunc { w.Header().Add(sk, sv) }) w.Write(ctx.Fasthttp.Response.Body()) + app.ReleaseCtx(ctx) }) }