Package feign.stream

Class StreamDecoder

  • All Implemented Interfaces:
    Decoder

    public final class StreamDecoder
    extends java.lang.Object
    implements Decoder
    Iterator based decoder that support streaming.

    Example:

     
     Feign.builder()
       .decoder(StreamDecoder.create(JacksonIteratorDecoder.create()))
       .doNotCloseAfterDecode() // Required for streaming
       .target(GitHub.class, "https://api.github.com");
     interface GitHub {
      @RequestLine("GET /repos/{owner}/{repo}/contributors")
       Stream contributors(@Param("owner") String owner, @Param("repo") String repo);
     }
     
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static StreamDecoder create​(Decoder iteratorDecoder)  
      java.lang.Object decode​(Response response, java.lang.reflect.Type type)
      Decodes an http response into an object corresponding to its generic return type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • decode

        public java.lang.Object decode​(Response response,
                                       java.lang.reflect.Type type)
                                throws java.io.IOException,
                                       FeignException
        Description copied from interface: Decoder
        Decodes an http response into an object corresponding to its generic return type. If you need to wrap exceptions, please do so via DecodeException.
        Specified by:
        decode in interface Decoder
        Parameters:
        response - the response to decode
        type - generic return type of the method corresponding to this response.
        Returns:
        instance of type
        Throws:
        java.io.IOException - will be propagated safely to the caller.
        DecodeException - when decoding failed due to a checked exception besides IOException.
        FeignException - when decoding succeeds, but conveys the operation failed.