Add body methods with Object parameter to WebFlux

The commit deprecates syncBody(Object) in favor of body(Object)
which has the same behavior in ServerResponse, WebClient and
WebTestClient. It also adds body(Object, Class) and
body(Object, ParameterizedTypeReference) methods in order to support
any reactive type that can be adapted to a Publisher via
ReactiveAdapterRegistry. Related BodyInserters#fromProducer
methods are provided as well.

Shadowed Kotlin body<T>() extensions are deprecated in favor of
bodyWithType<T>() ones, including dedicated Publisher<T> and
Flow<T> variants. Coroutines extensions are adapted as well, and
body(Object) can now be used with suspending functions.

Closes gh-23212
This commit is contained in:
Sebastien Deleuze
2019-07-07 21:03:41 +02:00
parent 0fbc9bf461
commit 2b4d6ce354
33 changed files with 781 additions and 270 deletions

View File

@@ -41,7 +41,7 @@ import org.springframework.util.MultiValueMap;
/**
* Builder for the body of a multipart request, producing
* {@code MultiValueMap<String, HttpEntity>}, which can be provided to the
* {@code WebClient} through the {@code syncBody} method.
* {@code WebClient} through the {@code body} method.
*
* Examples:
* <pre class="code">
@@ -67,7 +67,7 @@ import org.springframework.util.MultiValueMap;
*
* Mono&lt;Void&gt; result = webClient.post()
* .uri("...")
* .syncBody(multipartBody)
* .body(multipartBody)
* .retrieve()
* .bodyToMono(Void.class)
* </pre>