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

Method pruneAutoHeadRouteLocked

router.go:615–634  ·  view source on GitHub ↗

pruneAutoHeadRouteLocked removes an automatically generated HEAD route so a later explicit registration can take its place without duplicating handler chains. The caller must already hold app.mutex.

(path string)

Source from the content-addressed store, hash-verified

613// later explicit registration can take its place without duplicating handler
614// chains. The caller must already hold app.mutex.
615func (app *App) pruneAutoHeadRouteLocked(path string) {
616 headIndex := app.methodInt(MethodHead)
617 if headIndex == -1 {
618 return
619 }
620
621 norm := app.normalizePath(path)
622
623 headStack := app.stack[headIndex]
624 for i, headRoute := range slices.Backward(headStack) {
625 if headRoute.path != norm || headRoute.mount || headRoute.use || !headRoute.autoHead {
626 continue
627 }
628
629 app.stack[headIndex] = append(headStack[:i], headStack[i+1:]...)
630 app.hasRoutesRefreshed = true
631 atomic.AddUint32(&app.handlersCount, ^uint32(len(headRoute.Handlers)-1)) //nolint:gosec // G115 - handler count is always small
632 return
633 }
634}
635
636func (app *App) register(methods []string, pathRaw string, group *Group, handlers ...Handler) {
637 // A regular route requires at least one ctx handler

Callers 2

deleteRouteMethod · 0.95
addRouteMethod · 0.95

Calls 2

methodIntMethod · 0.95
normalizePathMethod · 0.95

Tested by

no test coverage detected