caddy/middleware/headers/new.go
2015-01-29 22:46:09 -07:00

25 lines
423 B
Go

package headers
import (
"net/http"
"github.com/mholt/caddy/middleware"
)
// New constructs and configures a new headers middleware instance.
func New(c middleware.Controller) (middleware.Middleware, error) {
rules, err := parse(c)
if err != nil {
return nil, err
}
return func(next http.HandlerFunc) http.HandlerFunc {
head := Headers{
Next: next,
Rules: rules,
}
return head.ServeHTTP
}, nil
}