ruanweihong-aaa opened a new pull request, #14201:
URL: https://github.com/apache/apisix/pull/14201
### Description
Add parameter-level query rewriting to `proxy-rewrite` through an optional
`args` object. This allows users to append, replace, or remove query parameters
without writing URI regular expressions.
- `add`: preserve existing values and append configured values; create
absent parameters.
- `set`: replace all values for a name; create absent parameters.
- `remove`: remove all values for a name.
Operations execute as `add -> set -> remove`, matching the current header
implementation. String and number values, including non-empty arrays, are
supported. Same-name value order and duplicates are preserved; different
parameter names and the original encoding representation may change. Values are
literal, without variable/template expansion.
The operations apply to the completed upstream URI, after URI rewriting and
before header rewriting. Omitting `args` leaves existing behavior unchanged.
For example:
```json
{
"args": {
"add": {"tag": ["b", "c"]},
"set": {"page": "1"},
"remove": ["token"]
}
}
```
`?tag=a&page=2&page=3&token=tmp` becomes equivalent to
`?tag=a&tag=b&tag=c&page=1`.
Includes English/Chinese documentation and tests for validation, repeated
values, operation precedence, encoding, URI composition, and configuration
reuse.
Fixes #11237
Discussion: https://github.com/apache/apisix/discussions/14190
The existing header-order documentation discrepancy is addressed separately
in #14196.
### Validation
- Lua syntax check and `git diff --check` passed.
- 31 checks passed in an APISIX/OpenResty container using the modified
source: 9 Lua test blocks and 22 gateway-to-echo HTTP requests.
- The unmodified baseline failed the feature checks.
- The full Test::Nginx harness was not run because the test image lacks
`Test::Nginx::Socket::Lua`. The four Admin API integration blocks in the added
test file have not been run through that harness.
### Checklist
- [x] I have explained the need for this PR and the problem it solves
- [x] I have explained the changes or the new features added to this PR
- [x] I have added tests corresponding to this change
- [x] I have updated the documentation to reflect this change
- [x] I have verified that this change is backward compatible
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]