0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00
caddy/middleware/headers/new.go
Matthew Holt 1e4baa53f0 Moved headers middleware into its own package
Further trying out spreading out the code outside of the nested functions
2015-01-29 22:05:05 -07:00

24 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
}