Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support var in upstream_uri on proxy-rewrite plugin #3139

Merged
merged 7 commits into from
Jan 5, 2021
Merged

feat: support var in upstream_uri on proxy-rewrite plugin #3139

merged 7 commits into from
Jan 5, 2021

Conversation

BFergerson
Copy link
Member

What this PR does / why we need it:

Adds the ability to use ctx.var in upstream_uri on the proxy-rewrite plugin.
Fixes #3133

added ability to use ctx.var in upstream_uri
@Firstsawyou
Copy link
Contributor

Need to add semantic "PR" title, for example: feat: ctx.var in upstream_uri on proxy-rewrite plugin

@Firstsawyou
Copy link
Contributor

We need test cases to cover this feature.

@spacewander
Copy link
Member

Please merge master to make CI pass.

@spacewander spacewander changed the title ctx.var in upstream_uri on proxy-rewrite plugin feat: support var in upstream_uri on proxy-rewrite plugin Dec 28, 2020
@spacewander
Copy link
Member

You can write test like

=== TEST 16: set route(rewrite uri args)
--- 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": "/plugin_proxy_rewrite_args"
}
},
"upstream": {
"nodes": {
"127.0.0.1:1980": 1
},
"type": "roundrobin"
},
"uri": "/hello"
}]]
)
if code >= 300 then
ngx.status = code
end
ngx.say(body)
}
}
--- request
GET /t
--- response_body
passed
--- no_error_log
[error]
=== TEST 17: rewrite uri args
--- request
GET /hello?q=apisix&a=iresty HTTP/1.1
--- response_body_like eval
qr/uri: \/plugin_proxy_rewrite_args(
q: apisix
a: iresty|
a: iresty
q: apisix)
/
--- no_error_log
[error]

t/plugin/proxy-rewrite.t Show resolved Hide resolved
doc/plugin-develop.md Outdated Show resolved Hide resolved
doc/plugin-develop.md Outdated Show resolved Hide resolved
@moonming
Copy link
Member

moonming commented Jan 5, 2021

ping @membphis

@moonming moonming merged commit 05b1db7 into apache:master Jan 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Combining basic-auth & proxy-rewrite
6 participants