diff --git a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt index 951f387832..392ef989a0 100644 --- a/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt +++ b/spring-webflux/src/main/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensions.kt @@ -50,7 +50,7 @@ inline fun ServerResponse.BodyBuilder.body(producer: Any): Mon body(producer, object : ParameterizedTypeReference() {}) /** - * Coroutines variant of [ServerResponse.BodyBuilder.body] with an [Any] parameter. + * Coroutines variant of [ServerResponse.BodyBuilder.bodyValue]. * * Set the body of the response to the given {@code Object} and return it. * This convenience method combines [body] and @@ -60,7 +60,7 @@ inline fun ServerResponse.BodyBuilder.body(producer: Any): Mon * @throws IllegalArgumentException if `body` is a [Publisher] or an * instance of a type supported by [org.springframework.core.ReactiveAdapterRegistry.getSharedInstance], */ -suspend fun ServerResponse.BodyBuilder.bodyAndAwait(body: Any): ServerResponse = +suspend fun ServerResponse.BodyBuilder.bodyValueAndAwait(body: Any): ServerResponse = bodyValue(body).awaitSingle() /** diff --git a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensionsTests.kt b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensionsTests.kt index 10c6971703..3ec6c29976 100644 --- a/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensionsTests.kt +++ b/spring-webflux/src/test/kotlin/org/springframework/web/reactive/function/server/ServerResponseExtensionsTests.kt @@ -69,7 +69,7 @@ class ServerResponseExtensionsTests { val body = "foo" every { bodyBuilder.bodyValue(ofType()) } returns Mono.just(response) runBlocking { - bodyBuilder.bodyAndAwait(body) + bodyBuilder.bodyValueAndAwait(body) } verify { bodyBuilder.bodyValue(ofType()) diff --git a/src/docs/asciidoc/web/webflux-functional.adoc b/src/docs/asciidoc/web/webflux-functional.adoc index 2cd17bb125..07325af011 100644 --- a/src/docs/asciidoc/web/webflux-functional.adoc +++ b/src/docs/asciidoc/web/webflux-functional.adoc @@ -351,7 +351,7 @@ found. If it is not found, we use `switchIfEmpty(Mono)` to return a 404 Not F suspend fun getPerson(request: ServerRequest): ServerResponse { // <3> val personId = request.pathVariable("id").toInt() - return repository.getPerson(personId)?.let { ok().contentType(APPLICATION_JSON).bodyAndAwait(it) } + return repository.getPerson(personId)?.let { ok().contentType(APPLICATION_JSON).bodyValueAndAwait(it) } ?: ServerResponse.notFound().buildAndAwait() } @@ -477,7 +477,7 @@ header: ---- val route = coRouter { (GET("/hello-world") and accept(MediaType.TEXT_PLAIN)).invoke { - ServerResponse.ok().bodyAndAwait("Hello World") + ServerResponse.ok().bodyValueAndAwait("Hello World") } } ----