2015-05-07 04:44:37 +08:00
|
|
|
package setup
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/mholt/caddy/middleware"
|
2015-06-10 15:48:41 +08:00
|
|
|
"github.com/mholt/caddy/middleware/inner"
|
2015-05-07 04:44:37 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
// 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 {
|
2015-06-10 15:48:41 +08:00
|
|
|
return inner.Internal{Next: next, Paths: paths}
|
2015-05-07 04:44:37 +08:00
|
|
|
}, 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
|
|
|
|
}
|