httprouter icon indicating copy to clipboard operation
httprouter copied to clipboard

RawPathRouting

Open imkira opened this issue 10 years ago • 1 comments

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?

imkira avatar Feb 09 '15 19:02 imkira

Any reason this hasn't been merged yet @julienschmidt? Has this functionality been included in some other way?

samsalisbury avatar Feb 06 '18 14:02 samsalisbury