use of reactivejson.ReactorObjectReader in project feign-reactive by kptfh.
the class JettyReactiveHttpResponse method body.
@Override
public Publisher<?> body() {
ReactorObjectReader reactorObjectReader = new ReactorObjectReader(jsonFactory);
Flux<ByteBuffer> content = directContent();
if (returnActualClass == ByteBuffer.class) {
return content;
} else if (returnActualClass.isAssignableFrom(String.class) && returnPublisherType == Mono.class) {
Charset charset = getCharset();
return content.map(byteBuffer -> charset.decode(byteBuffer).toString());
} else {
if (returnPublisherType == Mono.class) {
return reactorObjectReader.read(content, objectReader);
} else if (returnPublisherType == Flux.class) {
return reactorObjectReader.readElements(content, objectReader);
} else {
throw new IllegalArgumentException("Unknown returnPublisherType: " + returnPublisherType);
}
}
}
Aggregations