Also rewrite r.URL.Path, as gorilla mux reads this.

This commit is contained in:
Tom Wilkie
2016-05-23 16:18:24 +01:00
parent 3335361ae9
commit 8d092c37e7

View File

@@ -21,6 +21,7 @@ type pathRewrite struct {
func (p pathRewrite) Wrap(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
r.RequestURI = p.regexp.ReplaceAllString(r.RequestURI, p.replacement)
r.URL.Path = p.regexp.ReplaceAllString(r.RequestURI, p.replacement)
next.ServeHTTP(w, r)
})
}