Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r.RequestURI vs r.URL.Path #12

Closed
claudiofelber opened this issue Jul 3, 2015 · 1 comment
Closed

r.RequestURI vs r.URL.Path #12

claudiofelber opened this issue Jul 3, 2015 · 1 comment

Comments

@claudiofelber
Copy link

Is there a reason that you are using r.RequestURI instead of r.URL.Path. The problem with r.RequestURI ist that it does not work with http.StripPrefix, so the following code always returns a 404 because it does not notice that the "admin" prefix has been stripped off the path (http.StripPrefix does only modify r.URL.Path):

mux := httptreemux.New()
mux.GET("/", getIndex)
mux.GET("/users", getUsers)
mux.GET("/users/:id", getUser)
http.Handle("/admin/", http.StripPrefix("/admin", mux)
@dimfeld
Copy link
Owner

dimfeld commented Jul 3, 2015

This is the reason: https://code.google.com/p/go/issues/detail?id=3659

It should be pretty simple to make a config option to use r.URL.Path instead; I already have some code to do that if RequestURI is empty, which can happen with certain test code, so it should be easy to adapt that. I'll be glad to accept a PR if you want to take this on; otherwise I should probably have time next week to take care of it.

@dimfeld dimfeld closed this as completed in be02ab3 Jul 8, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants