Skip to content
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

Routing base on header value #290

Open
thomafred opened this issue Dec 15, 2022 · 3 comments
Open

Routing base on header value #290

thomafred opened this issue Dec 15, 2022 · 3 comments
Assignees
Labels
document Something worth documenting

Comments

@thomafred
Copy link
Contributor

thomafred commented Dec 15, 2022

Note: consider using Discussions to open a conversation about new features…

🚀 Feature Request

Hi there!

It would be able to route base on header value of a specific header.

For example:

@get("/my/path/{param}", header={"X-APPLICATION-HEADER": "somevalue"})
def my_handler(request: Request):
  ...

Value patterns could also be cool:

@get("/my/path/{param}", header={"X-APPLICATION-HEADER": "pattern-{matching}"})
def my_handler(request: Request, matching: str):
  ... 
@RobertoPrevato
Copy link
Member

Hi @thomafred
Sorry for taking so long to reply. Currently this is not supported but I like the idea of adding support for routing based on headers.

I am working on version 2 of the framework and related libraries. Right now adding support for dependency injection to authentication handlers and authorization requirements - I also plan to add full support for dependency injection to binders.
I can add support for routing based on HTTP headers (including host) and make it part of v2.

Can be related to #292

@RobertoPrevato
Copy link
Member

RobertoPrevato commented Apr 2, 2023

Hi @thomafred
Routing based on header value is now available in version 2 (which is still alpha) https://github.com/Neoteroi/BlackSheep/releases/tag/v2.0a5

However, there is no built-in handling of dynamic parameters like in your second example pattern-{matching} - but it is easy to define a custom filter that enables that scenario.
I'll document soon all new features and changes introduced with version 2.

@RobertoPrevato RobertoPrevato self-assigned this Apr 2, 2023
@RobertoPrevato RobertoPrevato added the document Something worth documenting label Apr 2, 2023
@thomafred
Copy link
Contributor Author

Awesome, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
document Something worth documenting
Projects
None yet
Development

No branches or pull requests

2 participants