spring-framework / org.springframework.web.reactive.function / BodyExtractors / toMono

toMono

open static fun <T : Any> toMono(elementClass: Class<out T>): BodyExtractor<Mono<T>, ReactiveHttpInputMessage>

Return a BodyExtractor that reads into a Reactor Mono.

Parameters

elementClass - the class of element in the Mono

- the element type

Return
a BodyExtractor that reads a mono

open static fun <T : Any> toMono(typeReference: ParameterizedTypeReference<T>): BodyExtractor<Mono<T>, ReactiveHttpInputMessage>

Return a BodyExtractor that reads into a Reactor Mono. The given ParameterizedTypeReference is used to pass generic type information, for instance when using the org.springframework.web.reactive.function.client.WebClient

 Mono<Map<String, String>> body = this.webClient .get() .uri("http://example.com") .exchange() .flatMap(r -> r.body(toMono(new ParameterizedTypeReference<Map<String,String>>() {}))); 

Parameters

typeReference - a reference to the type of element in the Mono

- the element type

Return
a BodyExtractor that reads a mono