diff options
author | lollipopkit🏳️⚧️ <[email protected]> | 2024-08-30 23:01:37 +0800 |
---|---|---|
committer | GitHub <[email protected]> | 2024-08-30 09:01:37 -0600 |
commit | 5c47c2f147e5bef44fc8cb48a655d31f5a2a817c (patch) | |
tree | b60c04ca9723521da8d1de3f8154e1e8158e74d8 /modules/caddyhttp/fileserver/caddyfile.go | |
parent | ffd28be90ab85206474739b1f479ef49a6f0d7c3 (diff) | |
download | caddy-5c47c2f147e5bef44fc8cb48a655d31f5a2a817c.tar.gz caddy-5c47c2f147e5bef44fc8cb48a655d31f5a2a817c.zip |
fileserver: browse: Configurable default sort (#6502)
* fileserver: add `sort` options
* fix: test
* fileserver: check options in `Provison`
* fileserver: more obvious err alerts in sort options
* fileserver: move `sort` to `browse`
---------
Co-authored-by: Matt Holt <[email protected]>
Diffstat (limited to 'modules/caddyhttp/fileserver/caddyfile.go')
-rw-r--r-- | modules/caddyhttp/fileserver/caddyfile.go | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/modules/caddyhttp/fileserver/caddyfile.go b/modules/caddyhttp/fileserver/caddyfile.go index 603a828c9..71b7638e4 100644 --- a/modules/caddyhttp/fileserver/caddyfile.go +++ b/modules/caddyhttp/fileserver/caddyfile.go @@ -119,6 +119,16 @@ func (fsrv *FileServer) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { return d.Err("Symlinks path reveal is already enabled") } fsrv.Browse.RevealSymlinks = true + case "sort": + for d.NextArg() { + dVal := d.Val() + switch dVal { + case sortByName, sortByNameDirFirst, sortBySize, sortByTime, sortOrderAsc, sortOrderDesc: + fsrv.Browse.SortOptions = append(fsrv.Browse.SortOptions, dVal) + default: + return d.Errf("unknown sort option '%s'", dVal) + } + } default: return d.Errf("unknown subdirective '%s'", d.Val()) } @@ -171,17 +181,6 @@ func (fsrv *FileServer) UnmarshalCaddyfile(d *caddyfile.Dispenser) error { } fsrv.EtagFileExtensions = etagFileExtensions - case "sort": - for d.NextArg() { - dVal := d.Val() - switch dVal { - case sortByName, sortBySize, sortByTime, sortOrderAsc, sortOrderDesc: - fsrv.SortOptions = append(fsrv.SortOptions, dVal) - default: - return d.Errf("unknown sort option '%s'", dVal) - } - } - default: return d.Errf("unknown subdirective '%s'", d.Val()) } |