Hi folks, a question: Do i gain something non-triv...
# coroutines
g
Hi folks, a question: Do i gain something non-trivial if i implement a contract in coroutines which is returning a reactor mono and is this simple?
Copy code
override fun handle(exchange: ServerWebExchange, ex: Throwable): Mono<Void> = mono {
    val mono = when (ex) {
        is DataBufferLimitException -> {
            exchange.response.let {
                it.statusCode = HttpStatus.BAD_REQUEST
                it.headers.contentType = MediaType.APPLICATION_JSON
                val responseBody = it.bufferFactory()
                    .wrap("""{"message":"file larger than 100 MB"}""".encodeToByteArray())
                it.writeWith(Mono.just(responseBody))
            }
        }
        // default spring error response
        else -> Mono.error(ex)
    }
    mono.awaitSingle()
}
On the other hand, if the contract is indeed more complex/time-consuming do i gain a non-trivial advantage if i use coroutines? I leave the option of needing to call another suspending fuinction out, because then it is mandatory to be in the coroutines world.