Response Transformer
What is the purpose of Response-Transformer?
Response Transformer is used to transform the response sent by the upstream server on the fly before returning the response to the client.
How are you able to enhance/customise your header?
You are able to do so by applying this yaml below into your own namespace:
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
name: response-transformer-example
config:
remove:
headers:
- x-toremove
- x-another-one
remove:
json:
- json-key-toremove
- another-json-key
add:
headers:
- x-new-header:value
- x-another-header:something
add:
json:
- new-json-key:some_value
- another-json-key:some_value
add:
json_types:
- new-json-key:string
- another-json-key:boolean
- another-json-key:number
append:
headers:
- x-existing-header:some_value
- x-another-header:some_value
plugin: response-transformerapiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: <your_ingress_name>
namespace: <your_namespace>
annotations:
konghq.com/plugins: response-transformer-example
.
spec:
ingressClassName: kong
.
. #rest of your yaml
.Things to take note of
The sequence flow of this yaml being applied is remove –> rename –> replace –> add –> append. Do note that if there is an existing header, add.headers does not work. You have to use append.headers instead.
To understand more about response transformer, you can visit https://docs.konghq.com/hub/kong-inc/response-transformer.