httprouter icon indicating copy to clipboard operation
httprouter copied to clipboard

Support for escaping parameters

Open jamescun opened this issue 8 years ago • 3 comments

I'm attempting to implement a REST API following the Google API Design guidelines, and have hit a snag while trying to implement Custom Methods.

Creating a route like /foo:customVerb will result in :customVerb becoming a parameter rather than part of the path. It would be helpful to be able to escape the parameter colon (perhaps like /foo\:customVerb).

jamescun avatar May 26 '17 11:05 jamescun

Agreed, it would be easy enough to make a PR for this. A simple check for a backslash escape when looking for colons and asterisks would be enough; better yet, also validate by making sure the colon or star is preceded by a path delimiter, because variables don't generally happen in the middle of words (though that may be desirable behavior). Would it help to make a PR?

david-l-riley avatar Jul 18 '18 13:07 david-l-riley

Liked gin gonic but have to choose another one for my project for the same reason.

bharat42 avatar May 03 '21 03:05 bharat42

Or allowing the named parameter prefix character/s to be specified at compile time, allowing alternatives to :

leefernandes avatar Apr 10 '23 14:04 leefernandes