0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00

headers: Changed Rule.Url to Rule.Path

Updated ServeHTTP comment to indicate that it is 
setting headers and not adding them to existing values.
This commit is contained in:
Peter Hellberg 2015-05-09 21:45:28 +02:00
parent a96c4d707b
commit b5fff09b54

View file

@ -18,10 +18,10 @@ type Headers struct {
}
// ServeHTTP implements the middleware.Handler interface and serves requests,
// adding headers to the response according to the configured rules.
// setting headers on the response according to the configured rules.
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) {
if middleware.Path(r.URL.Path).Matches(rule.Path) {
for _, header := range rule.Headers {
if strings.HasPrefix(header.Name, "-") {
w.Header().Del(strings.TrimLeft(header.Name, "-"))
@ -38,7 +38,7 @@ type (
// Rule groups a slice of HTTP headers by a URL pattern.
// TODO: use http.Header type instead?
Rule struct {
Url string
Path string
Headers []Header
}