Closed rast1025 closed 4 years ago
@rast1025 the usage of the status code as you described is not what your example shows.
the sequential response allows you to use elements of the previous response, so maybe you could combine it with some lua.
you can use no-op
pipes for checking the status code and take a decision as your described or you can implement your example with this config:
{
"endpoint": "/your-endpoint",
"extra_config": {
"github.com/devopsfaith/krakend/proxy": { "sequential": true }
},
"backend": [
{
"url_pattern": "//api/verify",
"host": ["http://host1.tld"],
"extra_config": {
"github.com/devopsfaith/krakend-lua/proxy/backend": {
"sources": [ "verify.lua" ],
"post": "check_response(response.load())",
"allow_open_libs": true
}
}
},
{
"url_pattern": "/{resp0_action}",
"host": ["http://host2.tld"]
}
]
}
and this lua snippet:
function check_response( resp )
local responseData = resp:data()
local limits = responseData:get("limits")
if limits:get("is_valid")
then
responseData:set("action", "increase")
else
responseData:set("action", "decrease")
end
end
This issue was marked as resolved a long time ago and now has been automatically locked as there has not been any recent activity after it. You can still open a new issue and reference this link.
I'm trying to configure my krakend.json using sequential proxy so that based on my backend's status code I can make one more request to another backend. Ex: If my 1st backend answers 201, I want to make request to 2nd backed, but if it answers 200, to another. Can I do it using krakend?