Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
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.
Matt Holt committed
May 5, 2020 at 12:34 UTC
1e8c9764df94c7b6549dc9f5be618cddc4573d1b
1 file changed
+3
-2
modules/caddyhttp/fileserver/matcher.go
+3
-2
@@ -91,7 +91,7 @@ func (MatchFile) CaddyModule() caddy.ModuleInfo {
91
92
// UnmarshalCaddyfile sets up the matcher from Caddyfile tokens. Syntax:
93
//
94
-// file {
94
+// file <files...> {
95
// root <path>
96
// try_files <files...>
97
// try_policy first_exist|smallest_size|largest_size|most_recently_modified
@@ -99,6 +99,7 @@ func (MatchFile) CaddyModule() caddy.ModuleInfo {
99
//
100
func (m *MatchFile) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
101
for d.Next() {
102
+ m.TryFiles = append(m.TryFiles, d.RemainingArgs()...)
103
for d.NextBlock(0) {
104
switch d.Val() {
105
case "root":
@@ -107,7 +108,7 @@ func (m *MatchFile) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
108
}
109
m.Root = d.Val()
110
case "try_files":
110
- m.TryFiles = d.RemainingArgs()
111
+ m.TryFiles = append(m.TryFiles, d.RemainingArgs()...)
112
if len(m.TryFiles) == 0 {
113
return d.ArgErr()
114
}