From 116943f184e55aeaaf3253718055a67c9ad082cb Mon Sep 17 00:00:00 2001 From: Alfonso Acosta Date: Wed, 8 Jun 2016 08:50:06 +0000 Subject: [PATCH] Rewrite net/http.Request.{URL.Path,RequestURI} consistently --- common/middleware/path_rewrite.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/middleware/path_rewrite.go b/common/middleware/path_rewrite.go index 5d5dd246c..65eb2e9f2 100644 --- a/common/middleware/path_rewrite.go +++ b/common/middleware/path_rewrite.go @@ -21,7 +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) + r.URL.Path = p.regexp.ReplaceAllString(r.URL.Path, p.replacement) next.ServeHTTP(w, r) }) } @@ -35,6 +35,7 @@ type pathReplace string func (p pathReplace) Wrap(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + r.URL.Path = string(p) r.RequestURI = string(p) next.ServeHTTP(w, r) })