Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gen: middleware support #659

Open
screwyprof opened this issue Nov 7, 2022 · 4 comments
Open

gen: middleware support #659

screwyprof opened this issue Nov 7, 2022 · 4 comments
Labels
enhancement New feature or request openapi-features OpenAPI features support issues

Comments

@screwyprof
Copy link

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:

  1. middleware which runs for all requests
  2. middleware that runs per endpoint

References

@screwyprof screwyprof added enhancement New feature or request openapi-features OpenAPI features support issues labels Nov 7, 2022
@ernado
Copy link
Member

ernado commented Nov 7, 2022

We have ogen/middleware (that is 1) and (2) looks like #566

@screwyprof
Copy link
Author

Thanks for the quick response.

@tdakkota
Copy link
Member

tdakkota commented Nov 7, 2022

Also, you could use Server.FindRoute method (2).

https://ogen.dev/docs/concepts/static_router/#findroute-method

@biancalana
Copy link

biancalana commented May 4, 2023

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request openapi-features OpenAPI features support issues
Projects
None yet
Development

No branches or pull requests

4 participants