-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Compose middleware only once. #565
Conversation
Should be more efficient, and means that middleware can hook in signal handlers for processing responses in a guaranteed order (once we have signals, of course).
I don't follow how signals can help? |
Ah, sorry. I was thinking it would help people that want to connect response_prepare signals in the same order that they've arranged their middleware. You'd have something like:
At the moment, middleware_factory is called once per request, which means it can't be used to do this kind of thing, leading to one having to plug in the signal handler separately, keeping the orders in sync if you move any of them around. |
People should subscribe for signal not in middleware but on application setup stage. Something like Is it makes a sense? |
Your PR looks like optimization (I don't know how it affects aiohttp performance). |
nested sub-applications, as in nesting routers? Sounds reasonable to me. I did play with a Host-based router at one point, but had trouble with making reverse lookups on routes work in an elegant way (i.e. Shall I profile the proposed change to see how useful it actually is, or perhaps look at the sub-app/route issue? |
That's up to you. Personally I curious about speed improvement after your change. Subapp support is a next big rock after signals, requires non-trivial changes. |
Close as nested apps are incompatible with PR. |
Should be more efficient, and means that middleware factories can hook in signal handlers
for processing responses in a guaranteed order (once we have signals, of
course).