summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorMatt Holt <mholt@users.noreply.github.com>2020-01-09 14:00:32 -0700
committerGitHub <noreply@github.com>2020-01-09 14:00:32 -0700
commit7527c0170558ce7e31b79b7bc31dbf2f25afd983 (patch)
treecab37e3b2af0ddd0bf4f17d635a318409f0b9104 /cmd
parent8aef859a5510e883a70fb562d5fb83c7585cc301 (diff)
v2: Implement Caddyfile enhancements (breaking changes) (#2960)
* http: path matcher: exact match by default; substring matches (#2959) This is a breaking change. * caddyfile: Change "matcher" directive to "@matcher" syntax (#2959) * cmd: Assume caddyfile adapter for config files named Caddyfile * Sub-sort handlers by path matcher length (#2959) Caddyfile-generated subroutes have handlers, which are sorted first by directive order (this is unchanged), but within directives we now sort by specificity of path matcher in descending order (longest path first, assuming that longest path is most specific). This only applies if there is only one matcher set, and the path matcher in that set has only one path in it. Path matchers with two or more paths are not sorted like this; and routes with more than one matcher set are not sorted like this either, since specificity is difficult or impossible to infer correctly. This is a special case, but definitely a very common one, as a lot of routing decisions are based on paths. * caddyfile: New 'route' directive for appearance-order handling (#2959) * caddyfile: Make rewrite directives mutually exclusive (#2959) This applies only to rewrites in the top-level subroute created by the HTTP caddyfile.
Diffstat (limited to 'cmd')
-rw-r--r--cmd/main.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/cmd/main.go b/cmd/main.go
index 564ef9f..d8e5f7b 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -134,6 +134,13 @@ func loadConfig(configFile, adapterName string) ([]byte, error) {
}
}
+ // as a special case, if a config file called "Caddyfile" was
+ // specified, and no adapter is specified, assume caddyfile adapter
+ // for convenience
+ if filepath.Base(configFile) == "Caddyfile" && adapterName == "" {
+ adapterName = "caddyfile"
+ }
+
// load config adapter
if adapterName != "" {
cfgAdapter = caddyconfig.GetAdapter(adapterName)