Skip to content
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

Spring Webfilters and Kotlin Coroutines #29672

Closed
akoufa opened this issue Dec 10, 2022 · 3 comments
Closed

Spring Webfilters and Kotlin Coroutines #29672

akoufa opened this issue Dec 10, 2022 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) theme: kotlin An issue related to Kotlin support type: enhancement A general enhancement
Milestone

Comments

@akoufa
Copy link

akoufa commented Dec 10, 2022

Hello and thanks for the great work. I am heavily using Spring Boot Webflux together with Kotlin and Coroutines. I wanted to ask, if it is planned to introduce a Coroutine aware Webclient and a suspending Webfilter. So instead of using

override fun filter(exchange: ServerWebExchange, chain: GatewayFilterChain): Mono<Void>
to be able to use something like the following:

override suspend fun filter(exchange: ServerWebExchange, chain: GatewayFilterChain)

I think having to use Reactor in some places and Coroutines in others does not allow for a consistent coding patterns for Spring Boot Kotlin users.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Dec 10, 2022
@sdeleuze sdeleuze added the theme: kotlin An issue related to Kotlin support label Dec 11, 2022
@sdeleuze
Copy link
Contributor

I agree that would be cleaner from a Kotlin perspective to be able to use only suspending function there. If we introduce a CoWebFilter Coroutines variant, we also need to introduce a CoWebFilterChain one.

@poutsma @rstoyanchev Any thoughts?

@poutsma poutsma self-assigned this Dec 12, 2022
@poutsma poutsma added type: enhancement A general enhancement in: web Issues in web modules (web, webmvc, webflux, websocket) labels Dec 13, 2022
@poutsma poutsma added this to the 6.0.5 milestone Jan 16, 2023
@poutsma poutsma removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Jan 16, 2023
@bragovo
Copy link

bragovo commented Mar 12, 2023

Hi, it's works find but is it possible to use contextWrite in CoWebFilterChain? I can't find a way to do that -(

@sdeleuze
Copy link
Contributor

If you are leveraging Coroutines, can you use Coroutines context instead for your use case?

mdeinum pushed a commit to mdeinum/spring-framework that referenced this issue Jun 29, 2023
This commit introduces the CoWebFilter, an abstract WebFilter
implementation that allows for coroutine usage.

Closes spring-projectsgh-29672
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) theme: kotlin An issue related to Kotlin support type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants