gen: middleware support
Description
At the moment the project uses a custom static router which doesn’t support middleware.
It would be great if it was possible to add support for different types of middleware:
- middleware which runs for all requests
- middleware that runs per endpoint
References
We have ogen/middleware (that is 1) and (2) looks like #566
Thanks for the quick response.
Also, you could use Server.FindRoute method (2).
https://ogen.dev/docs/concepts/static_router/#findroute-method
Would be great to have more information exposed (entire Route struct) inside the middleware context.
I came across a situation where I have a external module implementing the middleware that need the Route.pathPattern field. In that situation I can't use (1) because the Request struct doesn't have the needed field and (2) does not work because i can't/doesn't want to import generated code to be able to call FindRoute
Any ideas ?
We have ogen/middleware
How to add those middlewares? Docs has zero information about it.
Ok, we have created func Logging(logger *zap.Logger) middleware.Middleware {...} then what? How it would be in execution chain?