From eea68c34adb9217f1c6a536c152671d73ab5f682 Mon Sep 17 00:00:00 2001 From: Maxime Date: Sun, 12 Jul 2015 16:43:35 +0200 Subject: [PATCH] Changes regarding comment. Used http status code instead of a hardcoded value. Used url.Parse instead of url.ParseRequestURI, so that you can parse both absolute and relative URL. --- middleware/redirect/redirect.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/middleware/redirect/redirect.go b/middleware/redirect/redirect.go index e65b1078..00ca9483 100644 --- a/middleware/redirect/redirect.go +++ b/middleware/redirect/redirect.go @@ -23,9 +23,9 @@ func (rd Redirect) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error for _, rule := range rd.Rules { if rule.From == "/" { // Catchall redirect preserves path (TODO: Standardize/formalize this behavior) - toURL, err := url.ParseRequestURI(rule.To) + toURL, err := url.Parse(rule.To) if err != nil { - return 500, err + return http.StatusInternalServerError, err } newPath := toURL.Host + toURL.Path + r.URL.Path rmSlashs := regexp.MustCompile("//+")