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

Suspendable ServerRequestFilter in Resteasy Reactive #19013

Closed
mschorsch opened this issue Jul 27, 2021 · 7 comments · Fixed by #20529
Closed

Suspendable ServerRequestFilter in Resteasy Reactive #19013

mschorsch opened this issue Jul 27, 2021 · 7 comments · Fixed by #20529
Assignees
Labels
Milestone

Comments

@mschorsch
Copy link
Contributor

Description

The following return types are currently possible in Resteasy Reactive Filters (@ServerRequestFilter): void, Response, RestResponse, Optional<Response>, Optional<RestResponse>, Uni <Void>, Uni<RestResponse> or Uni <Response>.

Please add support for suspendable filters (Kotlin Coroutines).

Example

class Filters {

    @ServerRequestFilter(preMatching = true)
    suspend fun preMatchingFilter(requestContext: ContainerRequestContext): RestResponse<String>? {
        return if (requestContext.method == HttpMethod.GET) {
            RestResponse.ok("GET", MediaType.TEXT_PLAIN_TYPE)
        } else {
            null
        }
    }
}

Implementation ideas

No response

@mschorsch mschorsch added the kind/enhancement New feature or request label Jul 27, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Jul 27, 2021

@geoand
Copy link
Contributor

geoand commented Jul 27, 2021

This is certainly interesting (and I'll likely implement it for Quarkus 2.3), but may I ask what you plan to do in the filter that requires it to be a suspending function?

@mschorsch
Copy link
Contributor Author

mschorsch commented Jul 28, 2021

I am planning to call a suspend function in a service. The suspend function in the service makes an asynchronous request (a database call or a rest request).

In addition, it is already possible to return a Uni, so it would make sense to support Deferred as well.

Maybe it would be a good idea to support suspendable functions where Uni is already supported in Resteasy Reactive?

@geoand
Copy link
Contributor

geoand commented Jul 30, 2021

Yeah, we can certainly do that. But it will likely be a 2.3 enhancement, not a 2.2 one

@mschorsch
Copy link
Contributor Author

@geoand Ist there any chance that this will be in 2.4?

@geoand
Copy link
Contributor

geoand commented Oct 4, 2021

I'd say chances are slim, but it could happen.

@geoand
Copy link
Contributor

geoand commented Oct 4, 2021

#20529 introduces this feature

geoand added a commit to geoand/quarkus that referenced this issue Oct 4, 2021
geoand added a commit to geoand/quarkus that referenced this issue Oct 5, 2021
geoand added a commit that referenced this issue Oct 5, 2021
Allow suspend functions as to be uses as custom filters
@quarkus-bot quarkus-bot bot added this to the 2.4 - main milestone Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants