diff options
author | Mohammed Al Sahaf <[email protected]> | 2023-08-18 21:04:08 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2023-08-18 19:04:08 +0000 |
commit | 0a6d3333b2c92553e66c93c14d3258a790aac639 (patch) | |
tree | 3e25ab2dd9b746800b47ed9eeb9ccef1c2f09f36 /modules/caddyhttp/fileserver/staticfiles.go | |
parent | 568fd2b28618552d6d613bc15e423251cc14e93c (diff) | |
download | caddy-0a6d3333b2c92553e66c93c14d3258a790aac639.tar.gz caddy-0a6d3333b2c92553e66c93c14d3258a790aac639.zip |
fileserver: docs: clarify the ability to produce JSON array with `browse` (#5751)
Diffstat (limited to 'modules/caddyhttp/fileserver/staticfiles.go')
-rw-r--r-- | modules/caddyhttp/fileserver/staticfiles.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/modules/caddyhttp/fileserver/staticfiles.go b/modules/caddyhttp/fileserver/staticfiles.go index 4fe28d330..0ed558e8b 100644 --- a/modules/caddyhttp/fileserver/staticfiles.go +++ b/modules/caddyhttp/fileserver/staticfiles.go @@ -60,7 +60,23 @@ func init() { // requested directory does not have an index file, Caddy writes a // 404 response. Alternatively, file browsing can be enabled with // the "browse" parameter which shows a list of files when directories -// are requested if no index file is present. +// are requested if no index file is present. If "browse" is enabled, +// Caddy may serve a JSON array of the dirctory listing when the `Accept` +// header mentions `application/json` with the following structure: +// +// [{ +// "name": "", +// "size": 0, +// "url": "", +// "mod_time": "", +// "mode": 0, +// "is_dir": false, +// "is_symlink": false +// }] +// +// with the `url` being relative to the request path and `mod_time` in the RFC 3339 format +// with sub-second precision. For any other value for the `Accept` header, the +// respective browse template is executed with `Content-Type: text/html`. // // By default, this handler will canonicalize URIs so that requests to // directories end with a slash, but requests to regular files do not. |