membphis commented on a change in pull request #3139:
URL: https://github.com/apache/apisix/pull/3139#discussion_r549716648
##########
File path: t/plugin/proxy-rewrite.t
##########
@@ -1249,3 +1249,41 @@ version: nginx_var_does_not_exist
x-real-ip: 127.0.0.1
--- no_error_log
[error]
+
+
+
+=== TEST 42: set route(rewrite uri based on ctx.var)
Review comment:
I write a full test case example, you can make a try.
^_^
```
=== TEST 42: set route(rewrite uri based on ctx.var)
--- config
location /t {
content_by_lua_block {
local t = require("lib.test_admin").test
local code, body = t('/apisix/admin/routes/1',
ngx.HTTP_PUT,
[[{
"plugins": {
"proxy-rewrite": {
"uri": "/$arg_new_uri"
}
},
"upstream": {
"nodes": {
"127.0.0.1:1980": 1
},
"type": "roundrobin"
},
"uri": "/test"
}]]
)
if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- request
GET /t
--- response_body
passed
--- no_error_log
[error]
=== TEST 43: hit route(upstream uri: should be /hello)
--- request
GET /test?new_uri=hello
--- response_body
hello world
--- no_error_log
[error]
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]