-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write the ReactorContext from CoWebFilter #31319
Comments
Can you check if #27522 allow to do what you need? |
Hi. @Component
class TenantEncryptionKeyFilter : CoWebFilter() {
override suspend fun filter(exchange: ServerWebExchange, chain: CoWebFilterChain) {
val context = Context.of("hoge", "fuga").asCoroutineContext()
withContext(context) {
chain.filter(exchange)
}
}
} I have one question. CoWebFilter final override fun filter(exchange: ServerWebExchange, chain: WebFilterChain): Mono<Void> {
return mono(Dispatchers.Unconfined) {
filter(exchange, object : CoWebFilterChain {
override suspend fun filter(exchange: ServerWebExchange) {
// exchange.attributes[COROUTINE_CONTEXT_ATTRIBUTE] = currentCoroutineContext().minusKey(Job.Key)
chain.filter(exchange).awaitSingleOrNull()
}
})}.then()
} |
Not sure why |
Affects: <Spring Framework version>
I'm using Spring WebFlux.
I would like to be able to write to Context (ReactorContext) from CoWebFilter.
ReactorContext is implemented immutably, so if we can't write it like WebFilter, we won't be able to easily write it.
WebFilter example:
I want to write in a similar way using CoWebFilter.
The text was updated successfully, but these errors were encountered: