-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Non-wildcard routes that share a prefix with a wildcard route should take priority over the wildcard route #73
Comments
No, let me cite you from the README:
The special treatment of |
I'm sorry but "makes it great for SEO and improves the user experience"? First off, It has absolutely nothing to do with SEO, I don't know where you even got that idea. Second, a user now has to apply middleware or use the Defining wildcards as being fallbacks when there isn't an exact match gives a much more flexible API, much like the change I made in #72 for HTTP methods. It does not clutter or confuse the API. |
I just came across this problem and found this issue, so am replying here.
Can you suggest a way that it might be possible to continue to use httprouter for For example, if we wanted to serve something like this, with the
Your suggestion, I think, would be to make a custom handler |
I'm currently working on httprouter v2, for which I plan an (optional) less strict routing mode. |
👍 Looking forward to this feature. |
Looking at this and my code again, my needs might be a bit different. I need these two routes to play nicely with each other:
I was surprised to see this panic:
because, from the docs:
I would have expected Still kind of new to this router... maybe this is a separate issue? |
|
Currently it is impossible to do the following with httprouter:
This makes it impossible to do "enhanced" proxies and CMS'es that have completely dynamic URL's other than a control panel, just to name two practical examples.
To address this, I propose that URL's that share prefixes with wildcards would take priority over the wildcard. Effectively, they would have a higher weight. This is how I solved a similar problem in the Werkzeug WSGI library for Python.
In the above example, /api would take priority because it has a non-wildcard component in the same place as another route with a wildcard.
Combined with #72, this would also dramatically improve the ability to compose packages with httprouter.
The text was updated successfully, but these errors were encountered: