2015-01-14 03:43:45 +08:00
|
|
|
package config
|
|
|
|
|
2015-01-22 05:10:52 +08:00
|
|
|
import (
|
2015-05-04 20:53:54 +08:00
|
|
|
"github.com/mholt/caddy/config/parse"
|
|
|
|
"github.com/mholt/caddy/config/setup"
|
2015-03-26 23:52:03 +08:00
|
|
|
"github.com/mholt/caddy/middleware"
|
2015-01-22 05:10:52 +08:00
|
|
|
)
|
2015-01-19 14:11:21 +08:00
|
|
|
|
2015-01-14 03:43:45 +08:00
|
|
|
func init() {
|
2015-05-04 20:53:54 +08:00
|
|
|
// The parse package must know which directives
|
|
|
|
// are valid, but it must not import the setup
|
|
|
|
// or config package.
|
|
|
|
for _, dir := range directiveOrder {
|
|
|
|
parse.ValidDirectives[dir.name] = struct{}{}
|
|
|
|
}
|
|
|
|
}
|
2015-03-26 23:52:03 +08:00
|
|
|
|
2015-05-04 20:53:54 +08:00
|
|
|
var directiveOrder = []directive{
|
|
|
|
{"root", setup.Root},
|
|
|
|
{"tls", setup.TLS},
|
|
|
|
{"startup", setup.Startup},
|
|
|
|
{"shutdown", setup.Shutdown},
|
|
|
|
|
|
|
|
{"log", setup.Log},
|
|
|
|
{"gzip", setup.Gzip},
|
|
|
|
{"errors", setup.Errors},
|
|
|
|
{"header", setup.Headers},
|
|
|
|
{"rewrite", setup.Rewrite},
|
|
|
|
{"redir", setup.Redir},
|
|
|
|
{"ext", setup.Ext},
|
|
|
|
{"basicauth", setup.BasicAuth},
|
2015-05-05 01:04:17 +08:00
|
|
|
{"proxy", setup.Proxy},
|
|
|
|
{"fastcgi", setup.FastCGI},
|
2015-05-04 20:53:54 +08:00
|
|
|
// {"websocket", setup.WebSocket},
|
|
|
|
// {"markdown", setup.Markdown},
|
|
|
|
// {"templates", setup.Templates},
|
|
|
|
// {"browse", setup.Browse},
|
|
|
|
}
|
2015-03-26 23:52:03 +08:00
|
|
|
|
2015-05-04 20:53:54 +08:00
|
|
|
type directive struct {
|
|
|
|
name string
|
|
|
|
setup setupFunc
|
2015-01-14 03:43:45 +08:00
|
|
|
}
|
2015-05-04 20:53:54 +08:00
|
|
|
|
|
|
|
type setupFunc func(c *setup.Controller) (middleware.Middleware, error)
|