Skip to content

Commit 0a6d333

Browse files
authored
fileserver: docs: clarify the ability to produce JSON array with browse (#5751)
1 parent 568fd2b commit 0a6d333

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

modules/caddyhttp/fileserver/staticfiles.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,23 @@ func init() {
6060
// requested directory does not have an index file, Caddy writes a
6161
// 404 response. Alternatively, file browsing can be enabled with
6262
// the "browse" parameter which shows a list of files when directories
63-
// are requested if no index file is present.
63+
// are requested if no index file is present. If "browse" is enabled,
64+
// Caddy may serve a JSON array of the dirctory listing when the `Accept`
65+
// header mentions `application/json` with the following structure:
66+
//
67+
// [{
68+
// "name": "",
69+
// "size": 0,
70+
// "url": "",
71+
// "mod_time": "",
72+
// "mode": 0,
73+
// "is_dir": false,
74+
// "is_symlink": false
75+
// }]
76+
//
77+
// with the `url` being relative to the request path and `mod_time` in the RFC 3339 format
78+
// with sub-second precision. For any other value for the `Accept` header, the
79+
// respective browse template is executed with `Content-Type: text/html`.
6480
//
6581
// By default, this handler will canonicalize URIs so that requests to
6682
// directories end with a slash, but requests to regular files do not.

0 commit comments

Comments
 (0)