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 { ... }
}
foo()
val bar = coroutineContext[ReactorContext]?.context?.get<Bar>("bar")
FooFilter
our reactor context is emptyMono.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 wrongmono { foo() }
started working for me