-
Notifications
You must be signed in to change notification settings - Fork 100
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
Allow default route dependencies #705
Allow default route dependencies #705
Conversation
@alukach would you be able to review this one? 🙏 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM nice work!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice convenience feature. I think it makes sense. At first I thought a user should instead just do something like:
routes.add_route_dependencies(
app.router.routes,
[
{"path": route.path, "method": method, "type": "http"}
for route in app.router.routes
for method in route.methods
],
[Depends(auth.basic_auth)],
)
However, the value of being able to something like this seems really enticing:
routes.add_route_dependencies(
app.router.routes,
[
{"path": "*", "method": method, "type": "http"}
for method in ("POST", "PUT", "DELETE")
],
[Depends(auth.basic_auth)],
)
Left a minor code style suggestion, but 👍 💯
Co-authored-by: Anthony Lukach <anthonylukach@gmail.com>
Description:
Allows for
*
to be used for thepath
ormethod
variables in a route dependencies' scope to match all allowable routes.PR Checklist:
pre-commit
hooks pass locallymake test
)make docs
)