Skip to content

help request: how to rewrite upstream response  #8285

@yunduansing

Description

@yunduansing

Description

1.upstream body may response:
{ "data": [], "total": 100 }
http status code: 200

then I want to rewrite it like :
{ "data":{ "data": [],"total": 100} , "errcode": 0 }
http status code: 200

2.upstream body may response:
"Internal error."
http status code: 500

then I want to rewrite it like :
{ "msg": "Internal error.", "errcode": 500, "data": null }
http status code: 200

I want to know how to do it when I use the default response-rewrite plugin

Environment

  • APISIX version (run apisix version):
  • Operating system (run uname -a):
  • OpenResty / Nginx version (run openresty -V or nginx -V):
  • etcd version, if relevant (run curl http://127.0.0.1:9090/v1/server_info):
  • APISIX Dashboard version, if relevant:
  • Plugin runner version, for issues related to plugin runners:
  • LuaRocks version, for installation issues (run luarocks --version):

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions