summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conf_validation.c
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2019-10-09 15:26:59 +0300
committerValentin Bartenev <vbart@nginx.com>2019-10-09 15:26:59 +0300
commit75453479f3d1d1c865ed2e2a51618dd014642e6f (patch)
tree518279d745023269131f22bef4de74ae7aef9e30 /src/nxt_conf_validation.c
parent486b202cc10f9bb57859305046b9b7d843e39269 (diff)
downloadunit-75453479f3d1d1c865ed2e2a51618dd014642e6f.tar.gz
unit-75453479f3d1d1c865ed2e2a51618dd014642e6f.tar.bz2
Configuration: added check for mandatory options of "action".
Diffstat (limited to 'src/nxt_conf_validation.c')
-rw-r--r--src/nxt_conf_validation.c35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c
index c934b10b..206af85d 100644
--- a/src/nxt_conf_validation.c
+++ b/src/nxt_conf_validation.c
@@ -58,6 +58,8 @@ static nxt_int_t nxt_conf_vldt_listener(nxt_conf_validation_t *vldt,
static nxt_int_t nxt_conf_vldt_certificate(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data);
#endif
+static nxt_int_t nxt_conf_vldt_action(nxt_conf_validation_t *vldt,
+ nxt_conf_value_t *value, void *data);
static nxt_int_t nxt_conf_vldt_pass(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data);
static nxt_int_t nxt_conf_vldt_routes(nxt_conf_validation_t *vldt,
@@ -328,8 +330,8 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_route_members[] = {
{ nxt_string("action"),
NXT_CONF_VLDT_OBJECT,
- &nxt_conf_vldt_object,
- (void *) &nxt_conf_vldt_action_members },
+ &nxt_conf_vldt_action,
+ NULL },
NXT_CONF_VLDT_END
};
@@ -881,6 +883,35 @@ nxt_conf_vldt_listener(nxt_conf_validation_t *vldt, nxt_str_t *name,
static nxt_int_t
+nxt_conf_vldt_action(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
+ void *data)
+{
+ nxt_int_t ret;
+ nxt_conf_value_t *pass_value, *share_value;
+
+ static nxt_str_t pass_str = nxt_string("pass");
+ static nxt_str_t share_str = nxt_string("share");
+
+ ret = nxt_conf_vldt_object(vldt, value, nxt_conf_vldt_action_members);
+
+ if (ret != NXT_OK) {
+ return ret;
+ }
+
+ pass_value = nxt_conf_get_object_member(value, &pass_str, NULL);
+ share_value = nxt_conf_get_object_member(value, &share_str, NULL);
+
+ if (pass_value == NULL && share_value == NULL) {
+ return nxt_conf_vldt_error(vldt, "The \"action\" object must have "
+ "either \"pass\" or \"share\" "
+ "option set.");
+ }
+
+ return NXT_OK;
+}
+
+
+static nxt_int_t
nxt_conf_vldt_pass(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
void *data)
{