diff --git a/src/docs/asciidoc/web/webflux-functional.adoc b/src/docs/asciidoc/web/webflux-functional.adoc index 05156b523c..bbd597fccd 100644 --- a/src/docs/asciidoc/web/webflux-functional.adoc +++ b/src/docs/asciidoc/web/webflux-functional.adoc @@ -125,7 +125,7 @@ For more on that, see < person = webClient.get().retrieve().bodyToMono(Person.class); +ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(person); +---- +[source,kotlin,role="secondary"] +.Kotlin +---- +val person = webClient.get().retrieve().awaitBody() +ServerResponse.ok().contentType(MediaType.APPLICATION_JSON).body(person) +---- + +If not just the body, but also the status or headers are based on an asynchronous type, +you can use the static `async` method on `ServerResponse`, which +accepts `CompletableFuture`, `Publisher`, or +any other asynchronous type supported by the `ReactiveAdapterRegistry`. For instance: + +[source,java,role="primary"] +.Java +---- +Mono asyncResponse = webClient.get().retrieve().bodyToMono(Person.class) + .map(p -> ServerResponse.ok().header("Name", p.name()).body(p)); +ServerResponse.async(asyncResponse); +---- + [[webmvc-fn-handler-classes]] === Handler Classes