-
Notifications
You must be signed in to change notification settings - Fork 282
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
Support regex matching for URLRouter placeholders #1479
Comments
Another nice syntax could be |
Could this also be extended to add strong parameter types? ie. |
It won't work at that level, because the router takes runtime strings. But the |
I actually meant that for baked in regex patterns to match those types, so as to not have to repeat yourself over and over, whenever you want a URL parameter to match an integer, for example. |
Yes, but since it is based on a runtime parameter, that would mean that it can only work with a set of known types, which either limits its usefulness or makes for a relatively cumbersome interface (need to Generally, I don't think the router should be extended with high-level functionality, but should stay focused on it's main task of performing plain string matching as much as possible. Layering this on top is perfectly possible and avoids the mentioned issues, as the web interface generator shows. |
Fair point. Adding this sort of functionality in project-space is equally viable. |
A first step could be to add support for optional parameters that behave like this:
or in D code: @path("/foo/:var?", var)
void getFoo(string var = "defaultValue") At the moment having optional parameters in a
|
See #1062.
Suggested syntax coming from Python:
router.get("/items/:(?P<var>[0-9]+)/something/", ...)
The text was updated successfully, but these errors were encountered: