This commit is contained in:
Jingwen Owen Ou
2016-03-07 11:42:43 -08:00
parent 8ac5cf967f
commit 786d36e5ab
2 changed files with 12 additions and 12 deletions

12
mux.go
View File

@@ -79,12 +79,12 @@ func (r *Router) ServeHTTP(w http.ResponseWriter, req *http.Request) {
// Clean path to canonical form and redirect. // Clean path to canonical form and redirect.
if p := cleanPath(req.URL.Path); p != req.URL.Path { if p := cleanPath(req.URL.Path); p != req.URL.Path {
// Added 3 lines (Philip Schlump) - It was dropping the query string and #whatever from query. // Added 3 lines (Philip Schlump) - It was dropping the query string and #whatever from query.
// This matches with fix in go 1.2 r.c. 4 for same problem. Go Issue: // This matches with fix in go 1.2 r.c. 4 for same problem. Go Issue:
// http://code.google.com/p/go/issues/detail?id=5252 // http://code.google.com/p/go/issues/detail?id=5252
url := *req.URL url := *req.URL
url.Path = p url.Path = p
p = url.String() p = url.String()
w.Header().Set("Location", p) w.Header().Set("Location", p)
w.WriteHeader(http.StatusMovedPermanently) w.WriteHeader(http.StatusMovedPermanently)

View File

@@ -23,12 +23,12 @@ type Route struct {
matchers []matcher matchers []matcher
// Manager for the variables from host and path. // Manager for the variables from host and path.
regexp *routeRegexpGroup regexp *routeRegexpGroup
// If true, when the path pattern is "/path/", accessing "/path" will // If true, when the path pattern is "/path/", accessing "/path" will
// redirect to the former and vice versa. // redirect to the former and vice versa.
strictSlash bool strictSlash bool
// If true, when the path pattern is "/path//to", accessing "/path//to" // If true, when the path pattern is "/path//to", accessing "/path//to"
// will not redirect // will not redirect
skipClean bool skipClean bool
// If true, this route never matches: it is only used to build URLs. // If true, this route never matches: it is only used to build URLs.
buildOnly bool buildOnly bool
// The name used to build URLs. // The name used to build URLs.