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

Method Name

app.go:919–942  ·  view source on GitHub ↗

Name Assign name to specific route.

(name string)

Source from the content-addressed store, hash-verified

917
918// Name Assign name to specific route.
919func (app *App) Name(name string) Router {
920 app.mutex.Lock()
921 defer app.mutex.Unlock()
922
923 for _, routes := range app.stack {
924 for _, route := range routes {
925 isMethodValid := route.Method == app.latestRoute.Method || app.latestRoute.use ||
926 (app.latestRoute.Method == MethodGet && route.Method == MethodHead)
927
928 if route.Path == app.latestRoute.Path && isMethodValid {
929 route.Name = name
930 if route.group != nil {
931 route.Name = route.group.name + route.Name
932 }
933 }
934 }
935 }
936
937 if err := app.hooks.executeOnNameHooks(app.latestRoute); err != nil {
938 panic(err)
939 }
940
941 return app
942}
943
944// GetRoute Get route by name
945func (app *App) GetRoute(name string) Route {

Callers

nothing calls this directly

Calls 3

executeOnNameHooksMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65

Tested by

no test coverage detected