Dariusz Kuc
09/26/2019, 4:25 AMclass FooFilter : WebFilter {
override fun filter(exchange: ServerWebExchange, chain: WebFilterChain): Mono<Void> = mono {
foo()
}.flatMap { foo ->
chain.filter(exchange).subscriberContext { it.put("foo", foo) }
}
suspend fun foo(): Foo { ... }
}
Dariusz Kuc
09/26/2019, 4:27 AMfoo()
Dariusz Kuc
09/26/2019, 4:28 AMval bar = coroutineContext[ReactorContext]?.context?.get<Bar>("bar")
Dariusz Kuc
09/26/2019, 4:29 AMFooFilter
our reactor context is emptyDariusz Kuc
09/26/2019, 4:29 AMDariusz Kuc
09/26/2019, 3:12 PMMono.subscriberContext()
.flatMap { ctx ->
val foo = runBlocking(ctx.asCoroutineContext()) {
foo()
}
chain.filter(exchange).subscriberContext { it.put("foo", foo) }
}
seems to work... but that runBlocking
there seems just wrongDariusz Kuc
09/26/2019, 6:40 PMmono { foo() }
started working for meDariusz Kuc
09/26/2019, 6:40 PM