Skip to content

Conversation

@rhysrevans3
Copy link
Contributor

@rhysrevans3 rhysrevans3 commented Jun 10, 2024

Description:
Allows for * to be used for the path or method variables in a route dependencies' scope to match all allowable routes.

PR Checklist:

  • pre-commit hooks pass locally
  • Tests pass (run make test)
  • Documentation has been updated to reflect changes, if applicable, and docs build successfully (run make docs)
  • Changes are added to the CHANGELOG.

@rhysrevans3 rhysrevans3 marked this pull request as ready for review June 10, 2024 10:16
@vincentsarago
Copy link
Member

@alukach would you be able to review this one? 🙏

Copy link
Collaborator

@jonhealy1 jonhealy1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM nice work!

Copy link
Contributor

@alukach alukach left a 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 👍 💯

@vincentsarago vincentsarago merged commit 9a8ab84 into stac-utils:main Jun 12, 2024
@rhysrevans3 rhysrevans3 deleted the default_routes_dependency branch August 21, 2024 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants