httprouter
httprouter copied to clipboard
RawPathRouting
Thanks in advance for your awesome router.
golang's http package does (by default) percent-decode the URI path in requests, which cases problems during routing if the requested path contains %2f in named/catch-all parameters.
For instance, if I define the route GET /dirs/:dir/files/:file
, and make a request like GET /dirs/dir1%2fdir2/files/file
instead of having that route triggered, the NotFound handler will be executed because httprouter uses req.URL.Path which happens to expand to /dirs/dir1/dir2/files/file
.
The following thread mentions the importance of this detail. https://code.google.com/p/go/issues/detail?id=2782
This patch adds the option RawPathRouting
to Router. It is disabled by default because it is rarely necessary and because it forces the user to decode parameters manually if enabled. There are already other routers doing this, namely httptreemux
Would it be possible to merge this into your repo?
Any reason this hasn't been merged yet @julienschmidt? Has this functionality been included in some other way?