Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 12, 23:15 UTC
fileserver: docs: clarify the ability to produce JSON array with `browse` (#5751)
Mohammed Al Sahaf committed
Aug 18, 2023 at 21:04 UTC
0a6d3333b2c92553e66c93c14d3258a790aac639
1 file changed
+17
-1
modules/caddyhttp/fileserver/staticfiles.go
+17
-1
@@ -60,7 +60,23 @@ func init() {
60
// requested directory does not have an index file, Caddy writes a
61
// 404 response. Alternatively, file browsing can be enabled with
62
// 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`.
80
//
81
// By default, this handler will canonicalize URIs so that requests to
82
// directories end with a slash, but requests to regular files do not.