apisix icon indicating copy to clipboard operation
apisix copied to clipboard

Can response-rewrite support different httpStatus corresponding to different body

Open ipanocloud opened this issue 2 years ago • 7 comments

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

ipanocloud avatar Jul 27 '22 08:07 ipanocloud

Looks like you want the custom error page feature?

tokers avatar Jul 27 '22 08:07 tokers

want to return different response packets based on different httpstatus

ipanocloud avatar Jul 27 '22 08:07 ipanocloud

Let's see if there are more similar needs

tzssangglass avatar Jul 27 '22 16:07 tzssangglass

Let's see if there are more similar needs

This need is real in the business

ipanocloud avatar Jul 28 '22 01:07 ipanocloud

Looks like you want the custom error page feature?

want to return different response packets based on different httpstatus

ipanocloud avatar Jul 28 '22 01:07 ipanocloud

welcome PR to implement this @ipanocloud

moonming avatar Aug 08 '22 05:08 moonming

maybe base different body,not just status

stubbornTanzhe avatar Aug 09 '22 03:08 stubbornTanzhe

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.

kwanhur avatar Aug 10 '22 15:08 kwanhur

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.

github-actions[bot] avatar Jul 27 '23 10:07 github-actions[bot]

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.

github-actions[bot] avatar Aug 11 '23 10:08 github-actions[bot]