The Request Transformer policy allows to modify the response sent by the server on the fly on Express Gateway, before returning it back to the client
It can currently add/remove HTTP headers to the current response and add/remove properties to the response body, as long it’s JSON. It will skip the body modification in case the parsing operation does not succeed, sending the response to the client server untouched.
policies: - response-transformer
pipelines: pipeline1: apiEndpoints: - sampleEndpoint policies: - response-transformer: - action: body: add: hello: "'world'" headers: add: r-test: "'header value'" - proxy: - action: serviceEndpoint: backend
pipelines: pipeline1: apiEndpoints: - sampleEndpoint policies: - response-transformer: - action: body: add: hello: req.consumerId headers: add: r-test: req.requestId - proxy: - action: serviceEndpoint: backend
Note: Mind the difference between an expression and a constant string value. A constant string value must be quoted, so for example
"'world'" is a constant string value. An expression doesn’t need that:
req.consumerId is an expression.
- specification for the modifications to apply to the HTTP headers.
- specification for the modifications to apply to the HTTP body.
At least one of headers and body is required.
headers and body are defined as follows:
- an object describing the name and the value of the properties to add to the headers/body collection. The value can be an expression, so you can add values at runtime
- an array of properties that should be removed from the headers/body collection