AcquireCtx retrieves a new Ctx from the pool.
(fctx *fasthttp.RequestCtx)
| 64 | |
| 65 | // AcquireCtx retrieves a new Ctx from the pool. |
| 66 | func (app *App) AcquireCtx(fctx *fasthttp.RequestCtx) CustomCtx { |
| 67 | ctx, ok := app.pool.Get().(CustomCtx) |
| 68 | |
| 69 | if !ok { |
| 70 | panic(errCustomCtxTypeAssertion) |
| 71 | } |
| 72 | |
| 73 | app.setHandlerCtxIfNeeded(ctx) |
| 74 | |
| 75 | ctx.Reset(fctx) |
| 76 | |
| 77 | return ctx |
| 78 | } |
| 79 | |
| 80 | func (app *App) setHandlerCtxIfNeeded(ctx CustomCtx) { |
| 81 | if app.hasCustomCtx || isCustomCtx(ctx) { |