Commit 2743f978 authored by Matt Holt's avatar Matt Holt

Merge pull request #66 from stanislavromanov/master

Close #64 (Make it possible to remove headers)
parents 2501691e a5a90fe6
......@@ -5,6 +5,7 @@ package headers
import (
"net/http"
"strings"
"github.com/mholt/caddy/middleware"
)
......@@ -22,10 +23,14 @@ func (h Headers) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
for _, rule := range h.Rules {
if middleware.Path(r.URL.Path).Matches(rule.Url) {
for _, header := range rule.Headers {
if strings.HasPrefix(header.Name, "-") {
w.Header().Del(strings.TrimLeft(header.Name, "-"))
} else {
w.Header().Set(header.Name, header.Value)
}
}
}
}
return h.Next.ServeHTTP(w, r)
}
......
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