Hi, I was wondering if anybody can help me?
I am trying to run a response transformer in a golang api. For a better view, I receive the following when I trigger the sample below:
curl -i -X GET --url http://localhost:8000/ --header “Host: example”
“title”:“Power of Habit”,
I have added a response transformer as below:
curl -X POST --url http://localhost:8001/apis/example-api/plugins --data “name=response-transformer” --data “config.remove.json=isbn”
but somehow I am still getting the same results. the isbn is still present. I’m I missing something?
Thank you in advance.
The reason that this doesn’t work is that the current transformations don’t work with JSON arrays AFAIK:
for _, name in iter(conf.remove.json) do
json_body[name] = nil
It is a good idea though. E.g. add some detection of arrays here:
And if it is an array response, then do the remove in each object in array. Would you like to try send a pull-request for that?
Thank you for your reply @bungle!
I now understand the problem. I think the array checking would be useful.
A year after. Has this been implemented?
After all of these comments and a year after, I have the same problem, but here is not about array as I could see in other github questions. In my case is about a simple JSON object. Take a look at the image below:
As you can see, I tried some different combinations for the items in “remove json”, but I also have the same result. Take a look at the image below:
See? This plugin doesn’t work as expected for remove and isn’t only for remove, I tried to use “add” and it didn’t work too.
This Kong version which I’m using:
Someone else can help to solve this problem?
curl command instead of Postman, I think maybe cached on Postman