summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_controller.c
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2017-07-05 18:44:43 +0300
committerValentin Bartenev <vbart@nginx.com>2017-07-05 18:44:43 +0300
commit842aa9ab46ec5e065ac55b1d186ef9ea81c14af4 (patch)
treeb6504a70fa739bd082d1ae7a583b35e0a827baa4 /src/nxt_controller.c
parent4fe5d22dcc5d6e42c5faa6fe06dd076cde799324 (diff)
downloadunit-842aa9ab46ec5e065ac55b1d186ef9ea81c14af4.tar.gz
unit-842aa9ab46ec5e065ac55b1d186ef9ea81c14af4.tar.bz2
Configuration: basic validation of schema.
Diffstat (limited to 'src/nxt_controller.c')
-rw-r--r--src/nxt_controller.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/nxt_controller.c b/src/nxt_controller.c
index a3c0af17..757c294d 100644
--- a/src/nxt_controller.c
+++ b/src/nxt_controller.c
@@ -88,7 +88,7 @@ nxt_controller_start(nxt_task_t *task, nxt_runtime_t *rt)
nxt_http_fields_hash_t *hash;
static const nxt_str_t json
- = nxt_string("{ \"sockets\": {}, \"applications\": {} }");
+ = nxt_string("{ \"listeners\": {}, \"applications\": {} }");
hash = nxt_http_fields_hash_create(nxt_controller_request_fields,
rt->mem_pool);
@@ -593,6 +593,7 @@ nxt_controller_process_request(nxt_task_t *task, nxt_conn_t *c,
if (value == NULL) {
nxt_mp_destroy(mp);
status = 400;
+ nxt_str_set(&resp.json, "{ \"error\": \"Invalid JSON.\" }");
goto done;
}
@@ -620,6 +621,13 @@ nxt_controller_process_request(nxt_task_t *task, nxt_conn_t *c,
}
}
+ if (nxt_slow_path(nxt_conf_validate(value) != NXT_OK)) {
+ status = 400;
+ nxt_str_set(&resp.json,
+ "{ \"error\": \"Invalid configuration.\" }");
+ goto done;
+ }
+
nxt_mp_destroy(nxt_controller_conf.pool);
nxt_controller_conf.root = value;
@@ -674,6 +682,13 @@ nxt_controller_process_request(nxt_task_t *task, nxt_conn_t *c,
goto done;
}
+ if (nxt_slow_path(nxt_conf_validate(value) != NXT_OK)) {
+ status = 400;
+ nxt_str_set(&resp.json,
+ "{ \"error\": \"Invalid configuration.\" }");
+ goto done;
+ }
+
nxt_mp_destroy(nxt_controller_conf.pool);
nxt_controller_conf.root = value;
@@ -697,7 +712,6 @@ done:
case 400:
nxt_str_set(&resp.status_line, "400 Bad Request");
- nxt_str_set(&resp.json, "{ \"error\": \"Invalid JSON.\" }");
break;
case 404: