Java Code Examples for org.springframework.web.reactive.function.BodyExtractor

Following code examples demonstrate how to use org.springframework.web.reactive.function.BodyExtractorfrom spring-framework. These examples are extracted from various highly rated open source projects. You can directly use these code snippets or view their entire linked source code. These snippets are extracted to provide contextual information about how to use this class in the real world. These samples also let you understand some good practices on how to use org.springframework.web.reactive.function.BodyExtractorand various code implementation of this class.

    }

    private <T extends Publisher<?>> T bodyToPublisher(ClientResponse response,
                                                       BodyExtractor<T, ? super ClientHttpResponse> bodyExtractor,
                                                       BodyExtractor<T, ? super ClientHttpResponse> errorBodyExtractor) {
        return response.statusCode().isError() ?
                response.body(errorBodyExtractor) :
                response.body(bodyExtractor);
    } 


    static <T> BodyExtractor<Mono<T>, ClientHttpResponse> toMono(List<HttpErrorReader> httpErrorReaders) {
        return (inputMessage, context) -> readWithMessageReaders(
                inputMessage.getStatusCode(),
                httpErrorReaders,
                httpExceptionReader -> httpExceptionReader.readMono(inputMessage));
    } 

    static <T> BodyExtractor<Flux<T>, ClientHttpResponse> toFlux(List<HttpErrorReader> httpErrorReaders) {
        return (inputMessage, context) -> readWithMessageReaders(inputMessage.getStatusCode(),
                httpErrorReaders,
                httpExceptionReader -> httpExceptionReader.read(inputMessage));
    } 

Advertisement
Javadoc
A function that can extract data from a ReactiveHttpInputMessage body. @author Arjen Poutsma @since

5.0 @param the type of data to extract @param the type of ReactiveHttpInputMessage this extractor can be applied to @see BodyExtractors

Read More
Related Classes
Advertisement