Plugin for express-gateway that allows for transformation of response body when the response is an array.
Based on Response Transformation
policy that is built in to express-gateway. That policy only transforms the body if it's JSON, while this one transform array response body.
eg plugin install express-gateway-plugin-rewrite
- Ensure the plugin is included in
system.config.yml
file of your gateway. For example:
array-transformer:
package: express-gateway-plugin-array-transformer
Note: if you install the plugin using eg plugin create
, this will already be added.
- Add configuration to your
gateway.config.yml
file.
policies:
- array-transformer:
- action:
body:
add:
test: "'test'"
remove:
- hello
- world
action.add
: key-value pair to add to response body. The value can be a string (as above) or an expression. For example:
test: req.body.rTest
where rTest
is a key in request payload.
action.remove
: An array of keys to be removed.