-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Using per-endpoint middleware #518
Copy link
Copy link
Open
Labels
Milestone
Description
At the moment when RegisterHandlersWithBaseURL is generated there is no way to specify per-handler middleware. In our use case we need to use some middleware's on per-handler bases rather than global ones.
The EchoRouter interface has a 3rd param to pass on the middleware:
type EchoRouter interface {
CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
}
However there's no way to let RegisterHandlersWithBaseURL know about it. Is there any way to do it without having a global middleware which has to check whether it can be run for the given request?
Reactions are currently unavailable