-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
Literal colons in URLs #1432
Comments
Gin is using HttpRouter, maybe you can make pr on the HttpRouter. Or, You can using some/resource/name:customVerb then checking :customVerb is valid or not on the middleware.Although, It seems ugly, but it is easily than PR. |
More than ugly, it's not particularly efficient; a lot of httprouter's runtime efficiency is due to the absence of checks like this (they're all done at route build time, not query time). A PR wouldn't be hard, honestly. I'm happy to make one as long as my solution is acceptable. I asked here because Gin uses a customized fork of httprouter, so patching the upstream (which I've also proposed) won't help here. Echo has the same problem, FWIW... it seems like no one is considering this problem, which seems weird. |
@david-l-riley |
It's been part of the Google API design guide for quite a while for defining custom methods, but in general, I am surprised that the concept of escaping special characters in the URL definition isn't considered. It artificially constrains the available URL space when you make it impossible to use otherwise-valid characters in a URL, and a colon isn't an especially unusual one (an asterisk, maybe). Anyway, I've made a contribution to the discussion on the httprouter issue, and will make a PR there if need be; if anything comes of it, I'll note it here. |
Stumbled on the same issue here, the only reasonable solution seems to use another URL-valid character, like '~' or '.' |
encountered same issue. @wssccc 's pr looks nice. will it be accepted by next release? |
Hello is there any update on this matter? |
Does httprouter not support specifying a named parameter prefix alternatively to |
Hello is there any update on this matter? |
no news? |
fixed in #2857 |
I'm working on a project which uses literal colons in URLs to specify custom methods, as per the Google API Design Guidelines. The colons do not come after a slash, as one would expect a variable to, but the engine will detect them as variables anyway because it does a simple search for single colon or asterisk characters in tree.go (in several places).
I'd like to be able to include literal colons (not necessarily asterisks, though I don't see why not) in URLs because they're valid characters, either normally when they're not immediately after a path delimiter (do we really support having paths like
/root/version/something:variable
?) or if they're backslash-escaped. I can make a PR to do this, but I'd like to get a sense of what's preferred (if not both).The text was updated successfully, but these errors were encountered: