mirror of
https://github.com/caddyserver/caddy.git
synced 2025-01-07 11:28:48 +03:00
Merge pull request #66 from stanislavromanov/master
Close #64 (Make it possible to remove headers)
This commit is contained in:
commit
2743f97892
1 changed files with 6 additions and 1 deletions
|
@ -5,6 +5,7 @@ package headers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/mholt/caddy/middleware"
|
"github.com/mholt/caddy/middleware"
|
||||||
)
|
)
|
||||||
|
@ -22,7 +23,11 @@ func (h Headers) ServeHTTP(w http.ResponseWriter, r *http.Request) (int, error)
|
||||||
for _, rule := range h.Rules {
|
for _, rule := range h.Rules {
|
||||||
if middleware.Path(r.URL.Path).Matches(rule.Url) {
|
if middleware.Path(r.URL.Path).Matches(rule.Url) {
|
||||||
for _, header := range rule.Headers {
|
for _, header := range rule.Headers {
|
||||||
w.Header().Set(header.Name, header.Value)
|
if strings.HasPrefix(header.Name, "-") {
|
||||||
|
w.Header().Del(strings.TrimLeft(header.Name, "-"))
|
||||||
|
} else {
|
||||||
|
w.Header().Set(header.Name, header.Value)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue