Issue description
比如Nginx自带的响应内容替换库可以替换局部内容:http://nginx.org/en/docs/http/ngx_http_sub_module.html
sub_filter '<a href="http://127.0.0.1:8080/' '<a href="https://$host/';
比如还有个支持正则替换的库(印象中Openresty已默认支持):ngx_http_substitutions_filter_module,可以通过正则表达式来替换内容:
subs_filter_types text/html text/css text/xml;
subs_filter st(\d*).example.com $1.example.com ir;
subs_filter a.example.com s.example.com;
subs_filter http://$host https://$host;
但是我看APISIX的 response-rewrite 插件文档,好像只能支持完整替换,相当于直接将所有响应都换成插件设置的返回,并不支持部分内容替换:
curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
"methods": ["GET"],
"uri": "/test/index.html",
"plugins": {
"response-rewrite": {
"body": "{\"code\":\"ok\",\"message\":\"new json body\"}",
"headers": {
"X-Server-id": 3,
"X-Server-status": "on",
"X-Server-balancer_addr": "$balancer_ip:$balancer_port"
},
"vars":[
[ "status","==","200" ]
]
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:80": 1
}
}
}'
想问下这个插件是否支持部分替换或正则替换?如果不支持,APISIX有没有其他解决方案呢?
Environment
- apisix version (cmd:
apisix version): 2.10.0
Issue description
比如Nginx自带的响应内容替换库可以替换局部内容:http://nginx.org/en/docs/http/ngx_http_sub_module.html
比如还有个支持正则替换的库(印象中Openresty已默认支持):ngx_http_substitutions_filter_module,可以通过正则表达式来替换内容:
但是我看APISIX的 response-rewrite 插件文档,好像只能支持完整替换,相当于直接将所有响应都换成插件设置的返回,并不支持部分内容替换:
想问下这个插件是否支持部分替换或正则替换?如果不支持,APISIX有没有其他解决方案呢?
Environment
apisix version): 2.10.0