1
0
Fork 0

refactor: Enhance rules tests.

- refactor: change incorrect package.
- refactor: test readability.
This commit is contained in:
Fernandez Ludovic 2017-05-28 05:50:03 +02:00 committed by Ludovic Fernandez
parent cbccdd51c5
commit b6c5c14447
7 changed files with 171 additions and 150 deletions

View file

@ -5,9 +5,8 @@ import (
"strings"
)
const (
forwardedPrefixHeader = "X-Forwarded-Prefix"
)
// ForwardedPrefixHeader is the default header to set prefix
const ForwardedPrefixHeader = "X-Forwarded-Prefix"
// StripPrefix is a middleware used to strip prefix from an URL request
type StripPrefix struct {
@ -35,7 +34,7 @@ func (s *StripPrefix) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
func (s *StripPrefix) serveRequest(w http.ResponseWriter, r *http.Request, prefix string) {
r.Header[forwardedPrefixHeader] = []string{prefix}
r.Header.Add(ForwardedPrefixHeader, prefix)
r.RequestURI = r.URL.RequestURI()
s.Handler.ServeHTTP(w, r)
}