|
For now I know how to get the routes from this code: routes := echo.Echo.Routes()
for _, each := range routes {
fmt.Println(each.Method)
fmt.Println(each.Path)
fmt.Println(each.Name)
}How can I know which route is e := echo.New()
group1 := e.Group("/group1")
e.Use(middleware.Recover())
e.GET("/index", func(c echo.Context) error {
return c.String(200, "ok")
}, someMiddlewareFunc)
group1.GET("/test", func(c echo.Context) error {
return c.String(200, "ok")
})
group1.GET("/index", func(c echo.Context) error {
return c.String(200, "ok")
}, someMiddlewareFunc)For example, I wants to get this kind of output: // result is map[path_in_string]echo.MiddlewareFunc{}
result:= map[string][]echo.MiddlewareFunc{
"/": []{middleware.Recover}
"/index": []{someMiddlewareFunc},
"/group1/index": []{someMiddlewareFunc},
}It's OK that I use Lines 935 to 941 in 0ce7302 |
Answered by
aldas
Feb 15, 2023
Replies: 1 comment 7 replies
|
I doubt it is possible. Instead of going that way - create wrapper for adding routes and make it to store all relevant information. And even that way it could be hard to have "proper" name for middleware function as it could be some anonymous function |
7 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
v4.10.0#2337 added callback so you can create own global route registry