Add awaitExchangeOrNull extension function to reactive webclient

Closes gh-26778
This commit is contained in:
Gabriel
2021-04-08 14:39:53 -03:00
committed by Sébastien Deleuze
parent aff0d8efe7
commit e24b2e6b5d
2 changed files with 27 additions and 0 deletions

View File

@@ -90,6 +90,15 @@ suspend fun RequestHeadersSpec<out RequestHeadersSpec<*>>.awaitExchange(): Clien
suspend fun <T: Any> RequestHeadersSpec<out RequestHeadersSpec<*>>.awaitExchange(responseHandler: suspend (ClientResponse) -> T): T =
exchangeToMono { mono(Dispatchers.Unconfined) { responseHandler.invoke(it) } }.awaitSingle()
/**
* Variant of [WebClient.RequestHeadersSpec.awaitExchange] that allows a nullable return
*
* @since 5.3.8
*/
@Suppress("DEPRECATION")
suspend fun <T: Any> RequestHeadersSpec<out RequestHeadersSpec<*>>.awaitExchangeOrNull(responseHandler: suspend (ClientResponse) -> T?): T? =
exchangeToMono { mono(Dispatchers.Unconfined) { responseHandler.invoke(it) } }.awaitSingleOrNull()
/**
* Coroutines variant of [WebClient.RequestHeadersSpec.exchangeToFlux].
*