Closed asambeka closed 4 years ago
CleanPath should take care of that.
//
should not be treated as /
while parsing as it would create a different path for the same ressource, but the former should be corrected. That is what CleanPath does.
CleanPath is used be the default NotFound handler, if you use a custom one, you can use it manually.
I am using this with Negroni. Here is the snippet,
mux := httprouter.New()
v1vPattern := "/v1/:application/*object
mux.GET(v1vPattern, VGet)
mux.PUT(v1vPattern, VPut)
mux.DELETE(v1vPattern, Delete)
nhandle := negroni.Classic()
nhandle.UseHandler(mux)
nhandle.Run(HOST_PORT)
I don't have NotFound handler (unless negroni is doming something different). Any suggestions?
How about mux.NotFound
?
I have never used Negroni myself, but I think quite a few people do. Maybe someone of the people watching this repository can help you?
In the router.go I can see CleanPath being called line 367. If CleanPath is being called why is this not working? This appears to be a bug in CleanPlath.
CleanPath successfully corrects //v1/service/action
to /v1/service/action
. If there was / is a bug, it does not seem to be in httprouter.
While building the RestFul web service, faced this issue where following two URLs are handled differently: http://www.myhost.com/v1/service/action http://www.myhost.com//v1/service/action httprouter.Router is using pattern /v1/:controller/:method
I believe "//" should be treated as "/" while parsing. I am using latest code.