gorilla/handlers — pull request #3 by jagregory (2013-09-03 03:15:24+00:00)
Title: Handle url encoded url segments

Encoded URLs weren't being printed to the log properly. I think there's something odd about the Go fmt behaviour.

Before:

GET /search?Hello%20World%20Testing
27.0.0.1 - - [03/Sep/2013:13:02:46 +1000] "GET /search?q=Hello%20World%T(MISSING)esting HTTP/1.1" 200 110

Which is wrong, obviously. It seems Go is interpreting the %s in the encoding as format instructions, not quite sure why. To fix this I replace any % with %% (the Go fmt escape for a literal %).

After:

GET /search?Hello%20World%20Testing
27.0.0.1 - - [03/Sep/2013:13:02:46 +1000] "GET /search?q=Hello%20World%20Testing HTTP/1.1" 200 110

FYI: To get this working in tests properly, I had to change the use of `req.RequestURI` to `req.URL.RequestURI()` (which the Go docs recommend too) because the URL created in the test wasn't being used.