feign-reactive icon indicating copy to clipboard operation
feign-reactive copied to clipboard

Decoder Support

Open kdavisk6 opened this issue 7 years ago • 4 comments

Add Decoder Support during the response phase.

kdavisk6 avatar Aug 16 '18 17:08 kdavisk6

Do you mean feign.codec.Decoder ?

kptfh avatar Aug 17 '18 07:08 kptfh

Yes.

kdavisk6 avatar Aug 17 '18 14:08 kdavisk6

feign.codec.Decoder doesn't meant for reactive decoding. I suggest that exact implementation of ReactiveHttpClient should implement encoding/decoding. In case of implementation based on Spring WebClient I don't need encoding/decoding as Spring takes full responsibility.

kptfh avatar Aug 17 '18 15:08 kptfh

I agree, in this case, it should be the responsibility of a ReactiveHttpClient to support both encoding and decoding, as that's ideally where it would occur. SpringWebFlux is a high level construct, and is similar to OpenFeign's Client, and is implicitly performing the encoding and decoding for you.

With that said, this library should be able to allow for more than just a SpringWebFlux implementation. In order to do so, I am suggesting that we attempt to support the OpenFeign Encoder, Decoder, and Client constructs. For example, I think it would be great if this library could support using Reactor based constructs, with a Jackson encoder and decoder.

interface GitHub {
   @RequestLine("GET /repos/{owner}/{repo}/contributors")
   Flux<Contributor> getContributors(@Param("owner") String owner, @Param("repo") String repository);
}

GitHub gitHub = ReactiveFeign.builder()
   .encoder(new JacksonEncoder())
   .decoder(new JacksonDecoder())
   .client(new ApacheHttpClient()) // wraps in a ReactiveHttpClient
   .target(GitHub.class, "https://www.github.com");

kdavisk6 avatar Aug 17 '18 16:08 kdavisk6