I have two route configured as following
GET /api/store/{store_id}/books
GET /api/store/{store_id}
When an API call comes for the first URL without {store_id}
parameter, like /api/store//books
, Gorilla would somehow send a 301 /api/store/books
to client. This is causing me problem because it acutally matched the second route. Gorilla would treat books
as the {store_id}
parameter.
How do I configure Gorilla to return 404 or other error code when receiving //
in URLs?
I am using Gorilla v1.7.0.
By default mux will clean the URL. You can set the router.SkipClean(true)
parameter to avoid that.
When true, if the route path is "/path//to", it will remain with the double slash. This is helpful if you have a route like: /fetch/http://xkcd.com/534/