MCPcopy
hub / github.com/gofiber/fiber / defaultRequestHandler

Method defaultRequestHandler

router.go:427–452  ·  view source on GitHub ↗
(rctx *fasthttp.RequestCtx)

Source from the content-addressed store, hash-verified

425}
426
427func (app *App) defaultRequestHandler(rctx *fasthttp.RequestCtx) {
428 ctx, ok := app.acquireDefaultCtx(rctx)
429 if !ok {
430 app.customRequestHandler(rctx)
431 return
432 }
433 defer app.releaseDefaultCtx(ctx)
434
435 // Check if the HTTP method is valid
436 if ctx.methodInt == -1 {
437 _ = ctx.SendStatus(StatusNotImplemented) //nolint:errcheck // Always return nil
438 return
439 }
440
441 // Optional: check flash messages (hot path, see hasFlashCookie).
442 if hasFlashCookie(&ctx.fasthttp.Request.Header) {
443 ctx.Redirect().parseAndClearFlashMessages()
444 }
445
446 _, err := app.next(ctx)
447 if err != nil {
448 if catch := ctx.App().ErrorHandler(ctx, err); catch != nil {
449 _ = ctx.SendStatus(StatusInternalServerError) //nolint:errcheck // Always return nil
450 }
451 }
452}
453
454func (app *App) customRequestHandler(rctx *fasthttp.RequestCtx) {
455 ctx := app.AcquireCtx(rctx)

Calls 10

acquireDefaultCtxMethod · 0.95
customRequestHandlerMethod · 0.95
releaseDefaultCtxMethod · 0.95
nextMethod · 0.95
hasFlashCookieFunction · 0.85
ErrorHandlerMethod · 0.80
SendStatusMethod · 0.65
RedirectMethod · 0.65
AppMethod · 0.65

Tested by 1