fix: prefix handling on http router
This commit is contained in:
parent
99787287bb
commit
93a35ad251
|
@ -73,5 +73,5 @@ func handle(fn handleFunc, prefix string, store *storage.Storage, server *settin
|
|||
}
|
||||
})
|
||||
|
||||
return http.StripPrefix(prefix, handler)
|
||||
return stripPrefix(prefix, handler)
|
||||
}
|
||||
|
|
|
@ -56,11 +56,13 @@ func stripPrefix(prefix string, h http.Handler) http.Handler {
|
|||
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
p := strings.TrimPrefix(r.URL.Path, prefix)
|
||||
rp := strings.TrimPrefix(r.URL.RawPath, prefix)
|
||||
r2 := new(http.Request)
|
||||
*r2 = *r
|
||||
r2.URL = new(url.URL)
|
||||
*r2.URL = *r.URL
|
||||
r2.URL.Path = p
|
||||
r2.URL.RawPath = rp
|
||||
h.ServeHTTP(w, r2)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue