How to get Current route name using the middleware


#1

i read the docs there is naming on route

g = e.Group("/merchant")
middlewares.SetJwtMiddlewares(g)
g.GET("/transaction", handlers.MerchantGetTransaction, middlewares.RateLimit).Name = "merchant_transaction"

How can i get the prefix_name for current route using the middlewares.RateLimit ?
i want something to get “merchant_transaction” string


#2

I haven’t really tried to do it in any of my projects, but I think one could get the name of the route from inside the middleware like so:

for _, v := range c.Echo().Routes() {
    if v.Path == c.Path() {
        fmt.Println(v.Name)
        break
    }
}