Commit c6579488 authored by Matthew Holt's avatar Matthew Holt

Refactored redir middleware to return errors

parent a39e71ca
...@@ -41,15 +41,15 @@ func New(c middleware.Controller) (middleware.Middleware, error) { ...@@ -41,15 +41,15 @@ func New(c middleware.Controller) (middleware.Middleware, error) {
redirects = append(redirects, rule) redirects = append(redirects, rule)
} }
return func(next http.HandlerFunc) http.HandlerFunc { return func(next middleware.HandlerFunc) middleware.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) (int, error) {
for _, rule := range redirects { for _, rule := range redirects {
if r.URL.Path == rule.From { if r.URL.Path == rule.From {
http.Redirect(w, r, rule.To, rule.Code) http.Redirect(w, r, rule.To, rule.Code)
break break
} }
} }
next(w, r) return next(w, r)
} }
}, nil }, nil
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment