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

Supporting optional path parameter and regex match #18

Open
ashokgelal opened this issue Jan 29, 2020 · 2 comments
Open

Supporting optional path parameter and regex match #18

ashokgelal opened this issue Jan 29, 2020 · 2 comments

Comments

@ashokgelal
Copy link

ashokgelal commented Jan 29, 2020

Is it possible to mark a path parameter as optional? Something like route("GET", "/users/<user>/blogs/<blog>/posts/<post?>", handler("get user blog post")), where the last parameter <post> is optional.

Along the same line, it'd be great if rut supported regex match something like route("GET", "/img/<path:.*>", handler("get image")).

The regex one isn't that important but just a nice to have.

Thank you!

@danielnorberg
Copy link
Owner

The optional path parameter, could that be achieved using two different routes, one with the parameter, one without?

General regex match is a big undertaking and unlikely to be implemented. But smaller specific improvements are more feasible.

@ashokgelal
Copy link
Author

That's how I've started doing it - having two routes. But I think having just one route is cleaner. When you have multiple optional parameters, it kind of becomes cluttered.

I understand your concern about regex matching so don't worry about it. Thank you!

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

No branches or pull requests

2 participants