How do I preserve Context using `mono` function? ...
# rx
d
How do I preserve Context using
mono
function? In the example above
context.getPrincipal<Principal>()
retrieves data from Context
Copy code
@RestController
class ProfileResource {
    // this works well
    @GetMapping("/profile/classic")
    fun classic(context: ServerWebExchange): Mono<String> =
            context.getPrincipal<Principal>()
                    .map { c -> c.name }

    // this throws "No value received via onNext for awaitFirst"
    @GetMapping("/profile/coroutine")
    fun coroutine(context: ServerWebExchange) = mono {
        context.getPrincipal<Principal>()
            .awaitFirst().name
    }
}