Current Behavior
When I use the fault-injection plugin as:
curl http://127.0.0.1:9180/apisix/admin/routes/1 \
-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"plugins": {
"fault-injection": {
"abort": {
"http_status": 200,
"body": "{\"count\": $arg_count}"
}
}
},
"upstream": {
"nodes": {
"127.0.0.1:1980": 1
},
"type": "roundrobin"
},
"uri": "/hello"
}'
I get the response:
$ curl http://127.0.0.1:9080/hello\?count\=3
{"count": 3
Expected Behavior
It seems to be missing the right brace, although it's also to walk around by: "body": "{\"count\": ${arg_count}}"
Relevant code :
local resolve_var
do
local _ctx
local n_resolved
local pat = [[(?<!\\)\$\{?(\w+)\}?]]
...
Can it be modified to like [[(?<!\\)\$(\{(\w+)\}|(\w+))]]? Otherwise, expressions like ${a and $a} will both be extracted as variables, which seems a bit confusing.
Error Logs
No response
Steps to Reproduce
- Run APISIX via the Docker image.
- Using the above configuration and curl.
Environment
- APISIX version (run
apisix version):3.6.0
- Operating system (run
uname -a): NA
- OpenResty / Nginx version (run
openresty -V or nginx -V):openresty/1.21.4.2
- etcd version, if relevant (run
curl http://127.0.0.1:9090/v1/server_info):NA
- APISIX Dashboard version, if relevant: NA
- Plugin runner version, for issues related to plugin runners: NA
- LuaRocks version, for installation issues (run
luarocks --version): NA
Current Behavior
When I use the fault-injection plugin as:
I get the response:
Expected Behavior
It seems to be missing the right brace, although it's also to walk around by:
"body": "{\"count\": ${arg_count}}"Relevant code :
Can it be modified to like
[[(?<!\\)\$(\{(\w+)\}|(\w+))]]? Otherwise, expressions like${aand$a}will both be extracted as variables, which seems a bit confusing.Error Logs
No response
Steps to Reproduce
Environment
apisix version):3.6.0uname -a): NAopenresty -Vornginx -V):openresty/1.21.4.2curl http://127.0.0.1:9090/v1/server_info):NAluarocks --version): NA