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)
| 613 | // later explicit registration can take its place without duplicating handler |
| 614 | // chains. The caller must already hold app.mutex. |
| 615 | func (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 | |
| 636 | func (app *App) register(methods []string, pathRaw string, group *Group, handlers ...Handler) { |
| 637 | // A regular route requires at least one ctx handler |
no test coverage detected