-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Labels
Description
Issue Description
Is there a better way to get the current route from a middleware or handler, other than this:
//MetricsMiddleware is a echo.Handler wrapper for Metrics
func (mr *MetricsRecorder) MetricsMiddleware(next echo.HandlerFunc) echo.HandlerFunc {
return func(c echo.Context) error {
endpoint := "UNKNOWN"
for _, r := range c.Echo().Routes() {
if r.Method == c.Request().Method && r.Path == c.Path() {
endpoint = r.Name
}
}
err := next(c)
...
return err
}
}
Version/commit
v4.1.11
wreulicke, wangdrew, constantins2001, creekorful, vmlellis and 6 more