Routing base on header value
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):
...
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 https://github.com/Neoteroi/BlackSheep/discussions/292
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.
Awesome, thank you!