Open
Description
Current Behavior
when i use go runner to write rewrite plugin, if i did't return new args, the original args will lost.
Example:
http://example.org/api/test?x=1&y=2 use go-plugin-runner rewrite the path to /api/test2 the questring args x,y will lost.
Expected Behavior
expect the querystring args operate like the lua proxy-rewrite plugin process args. combine the original querystring to rewrited upstream.
var.upstream_uri = path + args...
maybe modify the code logic ext-plugin/init.lua could fix it.
now code logic
local len = rewrite:ArgsLength()
if len > 0 then
local changed = {}
for i = 1, len do
local entry = rewrite:Args(i)
local name = entry:Name()
local value = entry:Value()
if value == nil then
args[name] = nil
else
if changed[name] then
if type(args[name]) == "table" then
core.table.insert(args[name], value)
else
args[name] = {args[name], entry:Value()}
end
else
args[name] = entry:Value()
end
changed[name] = true
end
end
core.request.set_uri_args(ctx, args)
if path then
var.upstream_uri = path .. '?' .. var.args
end
end
modify logic, chang the combine path and args to if
outline:
local len = rewrite:ArgsLength()
if len > 0 then
local changed = {}
for i = 1, len do
local entry = rewrite:Args(i)
local name = entry:Name()
local value = entry:Value()
if value == nil then
args[name] = nil
else
if changed[name] then
if type(args[name]) == "table" then
core.table.insert(args[name], value)
else
args[name] = {args[name], entry:Value()}
end
else
args[name] = entry:Value()
end
changed[name] = true
end
end
end
core.request.set_uri_args(ctx, args)
if path then
var.upstream_uri = path .. '?' .. var.args
end
Error Logs
No response
Steps to Reproduce
- write a go plugin, use RequestFilter rewrite the request path
- the upstream can't recevie args, the args will lost
- example like https://example.org/api/test?x=1&y=2 the plugin rewrite the path r.SetPath([]byte("/api/test2"))
Environment
- APISIX version (run
apisix version
): - Operating system (run
uname -a
): - OpenResty / Nginx version (run
openresty -V
ornginx -V
): - etcd version, if relevant (run
curl http://127.0.0.1:9090/v1/server_info
): - APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run
luarocks --version
):
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
📋 Backlog