-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: run dependencies even when no route matches #66
Comments
On a related note, this could maybe address the issues in https://github.com/tiangolo/fastapi/releases/tag/0.74.0 if we change our execution model somehow. I'll have to think about it a bit. |
I'm thinking what might work is for |
So after a bit of testing, it looks like #66 (comment) will work if we want it to, but there is a big con: we need to dive into the routing and HTTP method matching, which are currently things that Starlette just handles, and provides no real hooks into. So this would mean a lot more code in Xpresso 😞 |
Currently the following test fails:
The reason for this is that the dependency DAG is not executed until a route is found.
The same applies to FastAPI.
This is a bit confusing, and prevents implementing logging, tracing, etc. as a dependency (usually you'd want to log 404s).
I think it should be possible to change this: we'd run each App's and Rotuer's dependencies as the request traverses through them.
It'd be roughly the same as what we are doing in
Operation
:xpresso/xpresso/routing/operation.py
Lines 50 to 58 in bf71495
Ideally this change would mean that anything you do with ASGI middleware you can do with dependencies (there's still a good reason to support both: there is generic ASGI middleware but not generic Xpresso dependencies).
The main con is that I expect this to have a relatively large impact on performance and make the implementation a lot messier.
These are two very good arguments for not supporting this usage.
The text was updated successfully, but these errors were encountered: