-
Notifications
You must be signed in to change notification settings - Fork 21
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
Support for Middlewares #41
Comments
Hi @tonychengchime, thanks for reaching out. Yes! Twirp has support for both "middlewares" and hooks. They're nothing like the ones you see in Starlette though. And for your use case, they're not ideal. For more nuanced use cases, twirp has the concept of hooks. Equivalent implementation in python. https://github.com/verloop/twirpy/blob/0.0.7/twirp/hook.py You can pass a hook with the kwarg like so, Since you want to do auth, you can use You can raise a I can post a more complete example tomorrow if that'll help. |
Hi Piyush, that was very helpful. I got what I need so I will close this ticket. Thanks |
Today I got some time to check starlette's middlewares again. @tonychengchime check the "Using middleware in other frameworks" section on https://www.starlette.io/middleware/ Twirpy is a standard ASGI app, so it should work for youad well. |
Hi, does Twirpy support Middlewares like Starlette? I'm trying to implement an auth layer and would like to do it in a Middleware.
I did not see in the documentation or code where to specify them.
Thanks
The text was updated successfully, but these errors were encountered: