I have a microservice which outputs following as a response. It's an HTTP_GET request which serves on http://localhost:8050/location?company=5
curl -X GET http://localhost:8050/location?company=5
{
"locations": [
{ "key": "1050", "lat": 24.000000000, "lon": 46.000000000 },
{ "key": "1254", "lat": 24.999999999, "lon": 46.999999999 }
]
}
And I also have a HTTP_POST request, which accepts list of keys and returns relevent branch details. it serves on http://localhost:8060/branches
and accepts a json array.
curl -X POST http://localhost:8060/branches -H 'Content-Type: application/json' -d '["1050","1254"]'
and the output would be
{
"branches": [
{ "key": "1050", "branch_name": "DC", "telephone": "+1 11 111 111" },
{ "key": "1254", "branch_name": "LA", "telephone": "+1 22 222 222" }
]
}
and I need the final merged output as following
{
"branches": [
{ "key": "1050", "branch_name": "DC", "telephone": "+1 11 111 111" },
{ "key": "1254", "branch_name": "LA", "telephone": "+1 22 222 222" }
],
"locations": [
{ "key": "1050", "lat": 24.000000000, "lon": 46.000000000 },
{ "key": "1254", "lat": 24.999999999, "lon": 46.999999999 }
]
}
I'm developing an api gateway using krakend and it'll do the above and serves on http://localhost:8080/findBranches?company=2
Here is my krakend-config.json
{
"version": 2,
"extra_config": {},
"timeout": "3000ms",
"cache_ttl": "300s",
"output_encoding": "json",
"name": "sample",
"endpoints": [
{
"endpoint": "/findBranches",
"method": "GET",
"extra_config": {
"github.com/devopsfaith/krakend/proxy": {
"sequential": true
}
},
"headers_to_pass": [ "*" ],
"querystring_params": [ "company" ],
"output_encoding": "json",
"concurrent_calls": 1,
"backend": [
{
"url_pattern": "/location",
"encoding": "json",
"method": "GET",
"host": [ "http://localhost:8050" ],
"disable_host_sanitize": true
},
{
"url_pattern": "/branches",
"encoding": "json",
"method": "POST",
"host": [ "http://localhost:8060" ],
"disable_host_sanitize": false
}
]
}
]
}
How do I manipulate the response of 1st backend and send it to the post request of the second?