apisix
apisix copied to clipboard
Can response-rewrite support different httpStatus corresponding to different body
Description
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 } } }'
比如:这里status=404 对应一个body 而 status=503 对应另外一个body
即不同的httpStatus对应不同的body
Looks like you want the custom error page feature?
want to return different response packets based on different httpstatus
Let's see if there are more similar needs
Let's see if there are more similar needs
This need is real in the business
Looks like you want the custom error page feature?
want to return different response packets based on different httpstatus
welcome PR to implement this @ipanocloud
maybe base different body,not just status
want to return different response packets based on different httpstatus
it's similar to Nginx error_page directive, which returns a different response body based on the response status code.
This issue has been marked as stale due to 350 days of inactivity. It will be closed in 2 weeks if no further activity occurs. If this issue is still relevant, please simply write any comment. Even if closed, you can still revive the issue at any time or discuss it on the [email protected] list. Thank you for your contributions.
This issue has been closed due to lack of activity. If you think that is incorrect, or the issue requires additional review, you can revive the issue at any time.