I am using feign client to connect to downstream service.
I got a requirement that when one of the downstream service endpoint returns 400 ( it's partial success scenario ) our service need this to be converted to 200 success with the response value.
I am looking for a best way of doing this.
We are using error decoder to handle the errors and the above conversion is applicable for only one endpoint not for all the downstream endpoints and noticed that decode() method should returns exception back.
You will need to create a customized
Clientto intercept theResponseearly enough to change the response status and not invoke theErrorDecoder. The simplest approach is to create a wrapper on an existing client and create a newResponsewith a200status. Here is an example when using Feign'sApacheHttpClient:This customized client can be used on any Feign client you need.