summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_http_route.c
diff options
context:
space:
mode:
authorAlejandro Colomar <alx.manpages@gmail.com>2021-12-09 03:00:23 +0100
committerAlejandro Colomar <alx.manpages@gmail.com>2022-05-30 12:42:18 +0200
commit9af5f369511eefea691a5cb6787a31ef3af53a0a (patch)
treea9660d5de232128ec98230a9fe16053410b0c6a1 /src/nxt_http_route.c
parent237ddbe1770485eab0723aac3a5dca92e1a0c5d9 (diff)
downloadunit-9af5f369511eefea691a5cb6787a31ef3af53a0a.tar.gz
unit-9af5f369511eefea691a5cb6787a31ef3af53a0a.tar.bz2
Static: supporting new "index" option.
This supports a new option "index" that configures a custom index file name to be served when a directory is requested. This initial support only allows a single fixed string. An example: { "share": "/www/data/static/$uri", "index": "lookatthis.htm" } When <example.com/foo/bar/> is requested, </www/data/static/foo/bar/lookatthis.html> is served. Default is "index.html". === nxt_conf_validator.c: Accept "index" as a member of "share", and make sure it's a string. === I tried this feature in my own computer, where I tried the following: - Setting "index" to "lookatthis.htm", and check that the correct file is being served (check both a different name and a different extension). - Not setting "index", and check that <index.html> is being served. - Settind "index" to an array of strings, and check that the configuration fails: { "error": "Invalid configuration.", "detail": "The \"index\" value must be a string, but not an array." }
Diffstat (limited to '')
-rw-r--r--src/nxt_http_route.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/nxt_http_route.c b/src/nxt_http_route.c
index 558dae9d..9200dc52 100644
--- a/src/nxt_http_route.c
+++ b/src/nxt_http_route.c
@@ -611,6 +611,11 @@ static nxt_conf_map_t nxt_http_route_action_conf[] = {
offsetof(nxt_http_action_conf_t, share)
},
{
+ nxt_string("index"),
+ NXT_CONF_MAP_PTR,
+ offsetof(nxt_http_action_conf_t, index)
+ },
+ {
nxt_string("chroot"),
NXT_CONF_MAP_STR,
offsetof(nxt_http_action_conf_t, chroot)