Name Assign name to specific route.
(name string)
| 917 | |
| 918 | // Name Assign name to specific route. |
| 919 | func (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 |
| 945 | func (app *App) GetRoute(name string) Route { |
nothing calls this directly
no test coverage detected