Custom decoder

Feign.builder() allows you to create a custom decoder and also allows you to add this decoder to the configuration of the Feign client to decode a response. You have to configure a non-default decoder if your interface returns some custom type or a type besides Response, String, byte[], or void. Let's see following example of using the feign-gson extension:

AccountService client = Feign.builder() 
                     .decoder(new GsonDecoder()) 
                     .target(AccountService.class, "http://ACCOUNT-                      SERVICE"); 

As you can see in the preceding code, GsonDecoder has been added as a response decoder to this Feign client. We can also create a custom decoder class for this Feign client.

Netflix Feign also supports Hystrix for the circuit-breaker pattern. Let's ...

Get Mastering Spring Boot 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.