1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 02:17:05 +00:00

thanks @getsentry for the montlhy sponsor

This commit is contained in:
Gerasimos (Makis) Maropoulos
2022-10-13 12:46:39 +03:00
parent 173de0f852
commit 53dde1b15d
4 changed files with 54 additions and 17 deletions

View File

@@ -1056,6 +1056,23 @@ func (api *APIBuilder) GetRoutes() []*Route {
return api.routes.getAll()
}
// CountHandlers returns the total number of all unique
// registered route handlers.
func (api *APIBuilder) CountHandlers() int {
uniqueNames := make(map[string]struct{})
for _, r := range api.GetRoutes() {
for _, h := range r.Handlers {
handlerName := context.HandlerName(h)
if _, exists := uniqueNames[handlerName]; !exists {
uniqueNames[handlerName] = struct{}{}
}
}
}
return len(uniqueNames)
}
// GetRoute returns the registered route based on its name, otherwise nil.
// One note: "routeName" should be case-sensitive.
func (api *APIBuilder) GetRoute(routeName string) *Route {