diff options
author | Zhidao HONG <z.hong@f5.com> | 2023-04-20 23:20:41 +0800 |
---|---|---|
committer | Zhidao HONG <z.hong@f5.com> | 2023-04-20 23:20:41 +0800 |
commit | 14d6d97bacf9b06ba340ebd4211b2f1b6ad417dd (patch) | |
tree | 68dd559c475cc0dffdf1254c75971fcae9a89ed5 /src/nxt_conf_validation.c | |
parent | 8843e30e8275aa70bf7eec11709cd5d12e32b4ae (diff) | |
download | unit-14d6d97bacf9b06ba340ebd4211b2f1b6ad417dd.tar.gz unit-14d6d97bacf9b06ba340ebd4211b2f1b6ad417dd.tar.bz2 |
HTTP: added basic URI rewrite.
This commit introduced the basic URI rewrite. It allows users to change request URI. Note the "rewrite" option ignores the contained query if any and the query from the request is preserverd.
An example:
"routes": [
{
"match": {
"uri": "/v1/test"
},
"action": {
"return": 200
}
},
{
"action": {
"rewrite": "/v1$uri",
"pass": "routes"
}
}
]
Reviewed-by: Alejandro Colomar <alx@nginx.com>
Diffstat (limited to '')
-rw-r--r-- | src/nxt_conf_validation.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/nxt_conf_validation.c b/src/nxt_conf_validation.c index 9059b2b3..c9aac790 100644 --- a/src/nxt_conf_validation.c +++ b/src/nxt_conf_validation.c @@ -669,6 +669,16 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_match_members[] = { }; +static nxt_conf_vldt_object_t nxt_conf_vldt_action_common_members[] = { + { + .name = nxt_string("rewrite"), + .type = NXT_CONF_VLDT_STRING, + }, + + NXT_CONF_VLDT_END +}; + + static nxt_conf_vldt_object_t nxt_conf_vldt_pass_action_members[] = { { .name = nxt_string("pass"), @@ -677,7 +687,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_pass_action_members[] = { .flags = NXT_CONF_VLDT_TSTR, }, - NXT_CONF_VLDT_END + NXT_CONF_VLDT_NEXT(nxt_conf_vldt_action_common_members) }; @@ -692,7 +702,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_return_action_members[] = { .flags = NXT_CONF_VLDT_TSTR, }, - NXT_CONF_VLDT_END + NXT_CONF_VLDT_NEXT(nxt_conf_vldt_action_common_members) }; @@ -736,7 +746,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_share_action_members[] = { #endif }, - NXT_CONF_VLDT_END + NXT_CONF_VLDT_NEXT(nxt_conf_vldt_action_common_members) }; @@ -747,7 +757,7 @@ static nxt_conf_vldt_object_t nxt_conf_vldt_proxy_action_members[] = { .validator = nxt_conf_vldt_proxy, }, - NXT_CONF_VLDT_END + NXT_CONF_VLDT_NEXT(nxt_conf_vldt_action_common_members) }; |