summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Holt <mholt@users.noreply.github.com>2020-05-05 12:34:58 -0600
committerGitHub <noreply@github.com>2020-05-05 12:34:58 -0600
commit1e8c9764df94c7b6549dc9f5be618cddc4573d1b (patch)
treee536c3e2f4330d6d7a665b809b983bcb50f0ad7c
parent41c7bd27b495ab9b5edca7afb0cf99d5e1b52944 (diff)
file_server: Accept files args in one-liner of Caddyfile matcher (#3298)
Previously, matching by trying files other than the actual path of the URI was: file { try_files <files...> } Now, the same can be done in one line: file <files...> As before, an empty file matcher: file still matches if the request URI exists as a file in the site root.
-rw-r--r--modules/caddyhttp/fileserver/matcher.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/caddyhttp/fileserver/matcher.go b/modules/caddyhttp/fileserver/matcher.go
index 1beb8ba..9144ca4 100644
--- a/modules/caddyhttp/fileserver/matcher.go
+++ b/modules/caddyhttp/fileserver/matcher.go
@@ -91,7 +91,7 @@ func (MatchFile) CaddyModule() caddy.ModuleInfo {
// UnmarshalCaddyfile sets up the matcher from Caddyfile tokens. Syntax:
//
-// file {
+// file <files...> {
// root <path>
// try_files <files...>
// try_policy first_exist|smallest_size|largest_size|most_recently_modified
@@ -99,6 +99,7 @@ func (MatchFile) CaddyModule() caddy.ModuleInfo {
//
func (m *MatchFile) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
for d.Next() {
+ m.TryFiles = append(m.TryFiles, d.RemainingArgs()...)
for d.NextBlock(0) {
switch d.Val() {
case "root":
@@ -107,7 +108,7 @@ func (m *MatchFile) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
}
m.Root = d.Val()
case "try_files":
- m.TryFiles = d.RemainingArgs()
+ m.TryFiles = append(m.TryFiles, d.RemainingArgs()...)
if len(m.TryFiles) == 0 {
return d.ArgErr()
}