summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_conf_validation.c
diff options
context:
space:
mode:
authorMax Romanov <max.romanov@nginx.com>2020-11-10 22:27:08 +0300
committerMax Romanov <max.romanov@nginx.com>2020-11-10 22:27:08 +0300
commit5fd2933d2e54a7b5781698a670abf89b1031db44 (patch)
tree7d682ba1785ac883760331b4d123b0c17eaed10e /src/nxt_conf_validation.c
parent4ca9ba34081c44f5d421b171ffaf874fb341d73f (diff)
downloadunit-5fd2933d2e54a7b5781698a670abf89b1031db44.tar.gz
unit-5fd2933d2e54a7b5781698a670abf89b1031db44.tar.bz2
Python: supporting ASGI legacy protocol.
Introducing manual protocol selection for 'universal' apps and frameworks.
Diffstat (limited to '')
-rw-r--r--src/nxt_conf_validation.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c
index 8e6279fa..fc521016 100644
--- a/src/nxt_conf_validation.c
+++ b/src/nxt_conf_validation.c
@@ -95,6 +95,8 @@ static nxt_int_t nxt_conf_vldt_return(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data);
static nxt_int_t nxt_conf_vldt_proxy(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data);
+static nxt_int_t nxt_conf_vldt_python_protocol(nxt_conf_validation_t *vldt,
+ nxt_conf_value_t *value, void *data);
static nxt_int_t nxt_conf_vldt_threads(nxt_conf_validation_t *vldt,
nxt_conf_value_t *value, void *data);
static nxt_int_t nxt_conf_vldt_thread_stack_size(nxt_conf_validation_t *vldt,
@@ -494,6 +496,10 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_python_members[] = {
.name = nxt_string("callable"),
.type = NXT_CONF_VLDT_STRING,
}, {
+ .name = nxt_string("protocol"),
+ .type = NXT_CONF_VLDT_STRING,
+ .validator = nxt_conf_vldt_python_protocol,
+ }, {
.name = nxt_string("threads"),
.type = NXT_CONF_VLDT_INTEGER,
.validator = nxt_conf_vldt_threads,
@@ -1361,6 +1367,26 @@ nxt_conf_vldt_proxy(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
static nxt_int_t
+nxt_conf_vldt_python_protocol(nxt_conf_validation_t *vldt,
+ nxt_conf_value_t *value, void *data)
+{
+ nxt_str_t proto;
+
+ static const nxt_str_t wsgi = nxt_string("wsgi");
+ static const nxt_str_t asgi = nxt_string("asgi");
+
+ nxt_conf_get_string(value, &proto);
+
+ if (nxt_strstr_eq(&proto, &wsgi) || nxt_strstr_eq(&proto, &asgi)) {
+ return NXT_OK;
+ }
+
+ return nxt_conf_vldt_error(vldt, "The \"protocol\" can either be "
+ "\"wsgi\" or \"asgi\".");
+}
+
+
+static nxt_int_t
nxt_conf_vldt_threads(nxt_conf_validation_t *vldt, nxt_conf_value_t *value,
void *data)
{