-
Notifications
You must be signed in to change notification settings - Fork 273
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
route parameters with type constraints #1127
Comments
This would be neat. |
@shumphrey I have a branch which works for simple type declarations for types available in |
Definitely sounds like a cool feature. @SysPete, you saying your branch already provides simple support for this? Is there a link look at it for the lazy? |
@bigpresh this is the commit with my initial implementation: https://github.com/SysPete/Dancer2/commit/ccdffaddaa30fb3b2ccc553cfc3561731d1ae370. No pod updates and no tests pushed yet but that will happen in the next day or so. Changes are really small. |
@bigpresh this feature depends on my Type::Tiny PR (hint, hint) and is not feature-complete: needs to support user-specified type library for starters. |
@SysPete No expectations. I like the idea of the route matching happening on arbitrary types. Currently, if we do a regex match, and the route doesn't match, it goes on to the next one. This allows two routes, one for a string, one for an int. |
@bigpresh, @shumphrey something close to what will appear in a PR can be seen here: https://github.com/SysPete/Dancer2/compare/feature/type_tiny...SysPete:feature/gh1127_route_params_with_types |
@bigpresh use of eval has been removed in favour of |
Excellent :) 👍 |
I'd like to hear from more people on the core team. @veryrusty @mickeyn @yanick @racke @cromedome anyone else? |
Interesting venue to explore. We could even do something like (off-the-cuff pseudo-code below)
|
As long as we still have the option for something like |
This might be a silly question (that's my specialty!) but what about paths that have parenthesis in them or brackets? (Depending on which one we choose.) |
According to RFC 1738, some characters are "unsafe" and perhaps we could/should use them in this, because they're expected not to exist in the URL itself:
Parenthesis aren't covered there, but square brackets, angle brackets, and curly braces are all unsafe and should be encoded. |
(parens) Plus, I have to check, but if I remember correctly And yeah, if [] and {} and not considered valid in urls, all the more reasons to use them. ==b o.o |
@yanick++ for the extra tidbit! :) |
So this has been sitting here a while. |
Resolved by #1476. Thank you! |
Would be nice to have type constraints for route parameters as suggested by @shadowcat-mst
The text was updated successfully, but these errors were encountered: