caddy/config/setup/internal.go
2015-05-06 22:44:37 +02:00

32 lines
626 B
Go

package setup
import (
"github.com/mholt/caddy/middleware"
"github.com/mholt/caddy/middleware/internal"
)
// Internal configures a new Internal middleware instance.
func Internal(c *Controller) (middleware.Middleware, error) {
paths, err := internalParse(c)
if err != nil {
return nil, err
}
return func(next middleware.Handler) middleware.Handler {
return internal.Internal{Next: next, Paths: paths}
}, nil
}
func internalParse(c *Controller) ([]string, error) {
var paths []string
for c.Next() {
if !c.NextArg() {
return paths, c.ArgErr()
}
paths = append(paths, c.Val())
}
return paths, nil
}