summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conf_validation.c
diff options
context:
space:
mode:
authorAxel Duch <axel.duch@nginx.com>2019-07-24 13:47:35 +0300
committerAxel Duch <axel.duch@nginx.com>2019-07-24 13:47:35 +0300
commit7785c96c1aea16dee0ec17403fda01b4f5ba41b3 (patch)
tree9abd736f0cfbfd6bea13685b1849ca4565dd1ce8 /src/nxt_conf_validation.c
parentb1165d2edc99daf8eef0e092e4ed6dcee9bce252 (diff)
downloadunit-7785c96c1aea16dee0ec17403fda01b4f5ba41b3.tar.gz
unit-7785c96c1aea16dee0ec17403fda01b4f5ba41b3.tar.bz2
Added routing based on request scheme.
Scheme matches exact string “http” or “https”.
Diffstat (limited to 'src/nxt_conf_validation.c')
-rw-r--r--src/nxt_conf_validation.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c
index bee82dd4..45c0eb41 100644
--- a/src/nxt_conf_validation.c
+++ b/src/nxt_conf_validation.c
@@ -72,6 +72,8 @@ static nxt_int_t nxt_conf_vldt_match_patterns_set(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value);
static nxt_int_t nxt_conf_vldt_match_patterns_set_member(
nxt_conf_validation_t *vldt, nxt_str_t *name, nxt_conf_value_t *value);
+static nxt_int_t nxt_conf_vldt_match_scheme_pattern(nxt_conf_validation_t *vldt,
+ nxt_conf_value_t *value, void *data);
static nxt_int_t nxt_conf_vldt_app_name(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data);
static nxt_int_t nxt_conf_vldt_app(nxt_conf_validation_t *vldt,
@@ -214,6 +216,11 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_match_members[] = {
&nxt_conf_vldt_match_patterns,
NULL },
+ { nxt_string("scheme"),
+ NXT_CONF_VLDT_STRING,
+ &nxt_conf_vldt_match_scheme_pattern,
+ NULL },
+
{ nxt_string("host"),
NXT_CONF_VLDT_STRING | NXT_CONF_VLDT_ARRAY,
&nxt_conf_vldt_match_patterns,
@@ -820,6 +827,28 @@ nxt_conf_vldt_match_pattern(nxt_conf_validation_t *vldt,
static nxt_int_t
+nxt_conf_vldt_match_scheme_pattern(nxt_conf_validation_t *vldt,
+ nxt_conf_value_t *value, void *data)
+{
+ nxt_str_t scheme;
+
+ static const nxt_str_t http = nxt_string("http");
+ static const nxt_str_t https = nxt_string("https");
+
+ nxt_conf_get_string(value, &scheme);
+
+ if (nxt_strcasestr_eq(&scheme, &http)
+ || nxt_strcasestr_eq(&scheme, &https))
+ {
+ return NXT_OK;
+ }
+
+ return nxt_conf_vldt_error(vldt, "The \"scheme\" can either be "
+ "\"http\" or \"https\".");
+}
+
+
+static nxt_int_t
nxt_conf_vldt_match_patterns_sets(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data)
{