I’m struggling to set up an API that modifies the response headers or body. The definitions of ‘path’ and related config items is fuzzy enough that I’m not clear on what should be what. Body transform problems and questions - #2 by Martin states that “Response transforms need to be targetted on the rewritten URL, not on the inbound one.” but that’s not helping me where I am in Tyk knowledge yet.
my api config file is:
{
“name”: “Recs”,
“slug”: “recs”,
“api_id”: “1”,
“org_id”: “1”,
“use_keyless”: true,
“definition”: {
“location”: “header”,
“key”: “x-api-version”
},
“response_processors”: [
{“name”: “header_injector”},
{“name”: “header_transform”},
{
“name”: “response_body_transform”,
“options”: {}
}
],
“version_data”: {
“not_versioned”: true,
“versions”: {
“Default”: {
“name”: “Default”,
“use_extended_paths”: true,
“extended_paths”: {
“transform_headers”: [
{
“add_headers”: {“x-widgets-secret”: “the-secret-widget-key-is-secret”},
“path”: “/recs/{id}”,
“method”: “GET”
}
],
“transform_response_headers”: [
{
“add_headers”: {“x-server-id”: “this-is-important”},
“path”: “/recs/{id}/”,
“method”: “GET”
}
]
}
}
}
},
“proxy”: {
“listen_path”: “/”,
“target_url”: “http://0.0.0.0:20011/”,
“strip_listen_path”: true
},
“active”: true
}
the header specified in transform_headers
is applied to the proxied request.
the request made during testing is, curl -I http://localhost:8022/recs/r90waeef9shidlk/
response body is as expected as well.
is there something more I need to install / enable to transform response headers/body? a config setting I’m missing? or, is there somewhere that clarifies what the ‘path’ should be in response transforms?
thanks!
dc