aboutsummaryrefslogtreecommitdiffhomepage
path: root/modules/caddyhttp/fileserver/caddyfile.go
diff options
context:
space:
mode:
authorMatt Holt <[email protected]>2024-12-20 10:55:02 -0700
committerGitHub <[email protected]>2024-12-20 10:55:02 -0700
commit86da4e8f56f3518bc053dd4f68a78c538a4aab5f (patch)
treebaaf259e90a81d56bf8a2999809d396a02fe1ea9 /modules/caddyhttp/fileserver/caddyfile.go
parent130c868e95dfd1a8b1d39fd217bc6378f6b72ec0 (diff)
parented1c594cdbddf89829eaf1174f414028577b432d (diff)
downloadcaddy-86da4e8f56f3518bc053dd4f68a78c538a4aab5f.tar.gz
caddy-86da4e8f56f3518bc053dd4f68a78c538a4aab5f.zip
Merge branch 'master' into transfer-encoding-matchtransfer-encoding-match
Diffstat (limited to 'modules/caddyhttp/fileserver/caddyfile.go')
-rw-r--r--modules/caddyhttp/fileserver/caddyfile.go29
1 files changed, 21 insertions, 8 deletions
diff --git a/modules/caddyhttp/fileserver/caddyfile.go b/modules/caddyhttp/fileserver/caddyfile.go
index 71b7638e4..80a37322b 100644
--- a/modules/caddyhttp/fileserver/caddyfile.go
+++ b/modules/caddyhttp/fileserver/caddyfile.go
@@ -16,6 +16,7 @@ package fileserver
import (
"path/filepath"
+ "strconv"
"strings"
"github.com/caddyserver/caddy/v2"
@@ -78,7 +79,7 @@ func (fsrv *FileServer) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
return d.ArgErr()
}
- for d.NextBlock(0) {
+ for nesting := d.Nesting(); d.NextBlock(nesting); {
switch d.Val() {
case "fs":
if !d.NextArg() {
@@ -129,15 +130,29 @@ func (fsrv *FileServer) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
return d.Errf("unknown sort option '%s'", dVal)
}
}
+ case "file_limit":
+ fileLimit := d.RemainingArgs()
+ if len(fileLimit) != 1 {
+ return d.Err("file_limit should have an integer value")
+ }
+ val, _ := strconv.Atoi(fileLimit[0])
+ if fsrv.Browse.FileLimit != 0 {
+ return d.Err("file_limit is already enabled")
+ }
+ fsrv.Browse.FileLimit = val
default:
return d.Errf("unknown subdirective '%s'", d.Val())
}
}
case "precompressed":
- var order []string
- for d.NextArg() {
- modID := "http.precompressed." + d.Val()
+ fsrv.PrecompressedOrder = d.RemainingArgs()
+ if len(fsrv.PrecompressedOrder) == 0 {
+ fsrv.PrecompressedOrder = []string{"br", "zstd", "gzip"}
+ }
+
+ for _, format := range fsrv.PrecompressedOrder {
+ modID := "http.precompressed." + format
mod, err := caddy.GetModule(modID)
if err != nil {
return d.Errf("getting module named '%s': %v", modID, err)
@@ -150,10 +165,8 @@ func (fsrv *FileServer) UnmarshalCaddyfile(d *caddyfile.Dispenser) error {
if fsrv.PrecompressedRaw == nil {
fsrv.PrecompressedRaw = make(caddy.ModuleMap)
}
- fsrv.PrecompressedRaw[d.Val()] = caddyconfig.JSON(precompress, nil)
- order = append(order, d.Val())
+ fsrv.PrecompressedRaw[format] = caddyconfig.JSON(precompress, nil)
}
- fsrv.PrecompressedOrder = order
case "status":
if !d.NextArg() {
@@ -263,7 +276,7 @@ func parseTryFiles(h httpcaddyfile.Helper) ([]httpcaddyfile.ConfigValue, error)
tryPolicy = h.Val()
switch tryPolicy {
- case tryPolicyFirstExist, tryPolicyLargestSize, tryPolicySmallestSize, tryPolicyMostRecentlyMod:
+ case tryPolicyFirstExist, tryPolicyFirstExistFallback, tryPolicyLargestSize, tryPolicySmallestSize, tryPolicyMostRecentlyMod:
default:
return nil, h.Errf("unrecognized try policy: %s", tryPolicy)
}