Commit 6bf36d92 authored by Matthew Holt's avatar Matthew Holt

Refactored proxy middleware to return errors

parent 076d4e0e
...@@ -24,8 +24,8 @@ func New(c middleware.Controller) (middleware.Middleware, error) { ...@@ -24,8 +24,8 @@ func New(c middleware.Controller) (middleware.Middleware, error) {
rules = append(rules, rule) rules = append(rules, 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 rules { for _, rule := range rules {
if middleware.Path(r.URL.Path).Matches(rule.from) { if middleware.Path(r.URL.Path).Matches(rule.from) {
...@@ -45,11 +45,11 @@ func New(c middleware.Controller) (middleware.Middleware, error) { ...@@ -45,11 +45,11 @@ func New(c middleware.Controller) (middleware.Middleware, error) {
// TODO: Construct this before; not during every request, if possible // TODO: Construct this before; not during every request, if possible
proxy := httputil.NewSingleHostReverseProxy(baseUrl) proxy := httputil.NewSingleHostReverseProxy(baseUrl)
proxy.ServeHTTP(w, r) proxy.ServeHTTP(w, r)
return 0, nil
} else {
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