public final class StreamDecoder extends Object implements Decoder
Example:
Feign.builder()
.decoder(StreamDecoder.create(JacksonIteratorDecoder.create()))
.doNotCloseAfterDecode() // Required for streaming
.target(GitHub.class, "https://api.github.com");
or
Feign.builder()
.decoder(StreamDecoder.create(JacksonIteratorDecoder.create(), (r, t) -> "hello world")))
.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);
}
Decoder.Default
Modifier and Type | Method and Description |
---|---|
static StreamDecoder |
create(Decoder iteratorDecoder) |
static StreamDecoder |
create(Decoder iteratorDecoder,
Decoder delegateDecoder) |
Object |
decode(Response response,
Type type)
Decodes an http response into an object corresponding to its
generic return type . |
static boolean |
isStream(Type type) |
public Object decode(Response response, Type type) throws IOException, FeignException
Decoder
generic return type
. If you need to
wrap exceptions, please do so via DecodeException
.decode
in interface Decoder
response
- the response to decodetype
- generic return type
of the
method corresponding to this response
.type
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.public static boolean isStream(Type type)
public static StreamDecoder create(Decoder iteratorDecoder)
public static StreamDecoder create(Decoder iteratorDecoder, Decoder delegateDecoder)
Copyright © 2012–2022 OpenFeign. All rights reserved.