summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conf.c
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2018-09-20 15:27:14 +0300
committerValentin Bartenev <vbart@nginx.com>2018-09-20 15:27:14 +0300
commita2eca97e89f4898ca3f3287038e3757f4f778161 (patch)
treea330f309ce1b35fe06be95422af6af2a1c352c0b /src/nxt_conf.c
parent8d844bc2aa78d5acc789c5865a62bedbeba76902 (diff)
downloadunit-a2eca97e89f4898ca3f3287038e3757f4f778161.tar.gz
unit-a2eca97e89f4898ca3f3287038e3757f4f778161.tar.bz2
Controller: addressing of array elements in requests.
Diffstat (limited to 'src/nxt_conf.c')
-rw-r--r--src/nxt_conf.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/nxt_conf.c b/src/nxt_conf.c
index 58eb2080..1aeafc06 100644
--- a/src/nxt_conf.c
+++ b/src/nxt_conf.c
@@ -409,6 +409,7 @@ nxt_conf_value_t *
nxt_conf_get_path(nxt_conf_value_t *value, nxt_str_t *path)
{
nxt_str_t token;
+ nxt_int_t index;
nxt_conf_path_parse_t parse;
parse.start = path->start;
@@ -427,7 +428,25 @@ nxt_conf_get_path(nxt_conf_value_t *value, nxt_str_t *path)
return NULL;
}
- value = nxt_conf_get_object_member(value, &token, NULL);
+ switch (value->type) {
+
+ case NXT_CONF_VALUE_OBJECT:
+ value = nxt_conf_get_object_member(value, &token, NULL);
+ break;
+
+ case NXT_CONF_VALUE_ARRAY:
+ index = nxt_int_parse(token.start, token.length);
+
+ if (index < 0 || index > NXT_INT32_T_MAX) {
+ return NULL;
+ }
+
+ value = nxt_conf_get_array_element(value, index);
+ break;
+
+ default:
+ return NULL;
+ }
if (value == NULL) {
return NULL;