Skip to content

araqnid/kotlin-coroutines-resteasy

Repository files navigation

Resteasy coroutine adapter

Kotlin build Maven Central

This allows responding to requests from a Kotlin coroutine, using Resteasy's (actually JAX-RS's) AsyncResponse support. What is Resteasy-specific is that when the coroutine is executing, the context data from ResteasyProviderFactory is kept available, so coroutines have access to context data about the request.

An example (from the tests):

    @GET
    @Produces("text/plain")
    fun respond(@Suspended asyncResponse: AsyncResponse) {
        coroutineScope.respondAsynchronously(asyncResponse) {
            delay(50)
            "hello world"
        }
    }

About

Adapt Resteasy asynchronous responder to Kotlin coroutines

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages