-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
Possible to have multiple RawContextMiddlewares? #112
Comments
I don't understand what is even the expectation of 2 middlewares. |
Subclassing needs aside, in larger ecosystems like ours, where we have several internal packages that have different middlewares that can be added to an application like chained building blocks for different purposes, this is needed. Couldn't the addition of a second middleware simply not attempt to recreate the context if it already exists? |
why should it? the only reason people would use the middleware is to create the context. |
First off, thank you for your hard work on this package!
We use this in a few places in our ecosystem, and now we are in a situation where we likely will need a few different plugins in the context middleware. Our current implementation is a private internal package which subclasses the middleware and allows internal fastapi consumers to add it to their stack. All works well, we have had no issues with this approach.
Now we are looking to add a second
RawContextMiddleware
subclass in a different package, and are looking to take the same approach. But when we went to implement it, we found that only the first middleware added would work, and the second would not.The engineer working on this got around it by pulling the plugin from one package and adding to the context middleware of the other, but this tightly couples them in ways we wish not to.
The expectation is that we should be able to do
and have both apply, chained, like other middlewares. Is there something in the codebase that prevents this expectation from happening?
The text was updated successfully, but these errors were encountered: