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

Support for flexible routes #3

Closed
avaly opened this issue Oct 28, 2014 · 4 comments
Closed

Support for flexible routes #3

avaly opened this issue Oct 28, 2014 · 4 comments
Assignees
Labels
Milestone

Comments

@avaly
Copy link

@avaly avaly commented Oct 28, 2014

Disclaimer: this is a duplicate post for hapijs/hapi#2058

According to http://hapijs.com/api#path-parameters and the actual implementation of routes in v7+, one can not register the following route: /{foo}-custom-string-{bar}, due to the restriction that a path segment can not contain more than one parameter.

This should be changed and it should allow the creation of more flexible routes. Not all users of hapi use it to create only API sites, some of us use it to run a user facing site where SEO and the public URL structure is important.

I know we can do this by using a single parameter for the whole segment and then parsing that parameter inside the handler method, but that ruins the whole idea of using a framework that handles these small things for you.

@ThomasCrevoisier

This comment has been minimized.

Copy link

@ThomasCrevoisier ThomasCrevoisier commented Oct 29, 2014

I don't if the hapi team wants to go in that direction, and is there are other frameworks supporting this ? (Just curious, this is the first time I see this). I could work on this and propose a PR, if needed.

@avaly

This comment has been minimized.

Copy link
Author

@avaly avaly commented Oct 29, 2014

This can be achieved with express via their router.param method or even by defining a route using regular expression (which gives the best flexibility).

Having some similar features would help expand the reach of the hapi framework.

@ThomasCrevoisier

This comment has been minimized.

Copy link

@ThomasCrevoisier ThomasCrevoisier commented Oct 30, 2014

Okay, I didn't know about it. Thanks ^^ But how will you handle the case ```/{foo*2}-custom-string-{bar} ? I don't know for the moment if this will break a lot of logic.

@avaly

This comment has been minimized.

Copy link
Author

@avaly avaly commented Oct 30, 2014

Well, I guess you shouldn't be allowed to use /{foo*2}-custom-string-{bar}, but only allow using multiple single parameters within the same segment.

@hueniverse hueniverse added the request label Nov 20, 2014
@hueniverse hueniverse added this to the 2.0.0 milestone Nov 21, 2014
@hueniverse hueniverse self-assigned this Nov 21, 2014
@Marsup Marsup added feature and removed request labels Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.