-
-
Notifications
You must be signed in to change notification settings - Fork 937
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
Include responder in middleware process_resource #1629
Comments
Hi 👋, Thanks for using Falcon. The large amount of time and effort needed to Please consider helping us secure the future of the Falcon framework with a Thank you for your support! |
Hi @timc13! For the time being, note that the request object already exposes the A couple of alternative ideas off the top of my head:
|
Those seem like fine workarounds - although maybe a bit indirect. As far as i'm concerned, it's not the suffix that is important or need be exposed, it's the actual responder method itself and perhaps the method name. As a counterpoint, I think this proposal - #709 is also a good idea. If a custom My ultimate wish, is to be able to decorate responder methods and attach some metadata to them at declaration time. Then my middleware could Is there a trade-off to exposing the |
Just adding more parameters to the middleware interface is a bit of a trade-off in itself; both from the compatibility point of view (we'll have to provide shims), and well as just keeping the arity reasonably low. The mentioned idea from #709 is also a possible way to solve this. |
FWIW, this was raised again (on Gitter), see also #1818. There, I was thinking to myself, maybe we could define a |
I like the idea. A drawback to |
Yes, sorry, I merely meant that these objects must be reasonably fast to access, and ideally immutable, but their instantiation may take time since that would happen only upon adding/reshuffling routes. Edit: good to know they are slow even to access, sounds like that defeats the purpose a bit. |
py 3.8 mostly fixed them, but before it the access to named attributes of a named tuple was basically implemented as a |
It still benchmarks slightly slower than a normal attribute on a bare class object, but the difference is rather negligible. Much faster than a normal property. |
I like the flexibility that responder name suffixes offers - it would be great if this flexibility were extended to the middleware. For example, when writing middleware, you cannot distinguish between a non-suffixed responder and a suffixed responder for any given HTTP method.
A nice API for this might be to pass down the actual responder callable to the
process_resource
hookThe text was updated successfully, but these errors were encountered: