-
Notifications
You must be signed in to change notification settings - Fork 18k
proposal: net/http: support slash (/) in path variable #70601
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
Comments
CC @jba |
I think that if we allowed "..." wildcards in the middle, checking two patterns for conflict would become superlinear. I'm not positive, but that's my feeling. If there were just one wildcard, as in your example, it would be easy, but with multiple ones it seems hard. If you want to match a fixed number of segments, you can write one pattern for each. I think this is a likely decline. |
My specific use case has a lot of apis for resource_name, and resource_name allows for any number of slashes in it, I would need to make many (easily 20+) patterns, which is not maintainable. Third-party server mux (I think gorilla, chi, etc...) you can do this. But it would be really nice if you can do this with without a third-party library. |
Typically, something like that goes at the end of the path. For example, Google Cloud Platform URLs work like that. In some cases I believe they add a |
I agree that there are better ways to implement this, I'm familiar with those api standards, unfortunately some existing apis I cannot change. I appreciate your time and understanding in reviewing this proposal. |
Proposal Details
It would be really nice if the path variables can support / in the variable, example
GET /api/{resource_name}/components/info
only matches/api/resource_name/components/info
, and not/api/resource/name/components/info
. You can url encode the slash in resource name likeresource%2fname
, and that does work, but not what I'm looking for.I understand we may not want to default handle / in the path variable, but maybe an option to enable it, like
{resource_name/2}
for 2 slashes and{resource_name/*}
for any amount.You also cant do
GET /api/{resource_name...}/components/info
, which would also solve the issue I'm proposing.Example go code
The text was updated successfully, but these errors were encountered: