diff --git a/build.gradle.kts b/build.gradle.kts index c05dc57..e911ed2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -79,7 +79,7 @@ allprojects { withType { kotlinOptions { jvmTarget = "1.8" - freeCompilerArgs = listOf("-Xuse-experimental=kotlin.Experimental") + freeCompilerArgs = listOf("-opt-in=kotlin.RequiresOptIn") } } diff --git a/kert-http/src/main/kotlin/ws/leap/kert/http/HttpRouter.kt b/kert-http/src/main/kotlin/ws/leap/kert/http/HttpRouter.kt index 9ae030c..6dba57e 100644 --- a/kert-http/src/main/kotlin/ws/leap/kert/http/HttpRouter.kt +++ b/kert-http/src/main/kotlin/ws/leap/kert/http/HttpRouter.kt @@ -5,10 +5,7 @@ import io.vertx.core.http.HttpMethod import io.vertx.ext.web.Router import io.vertx.kotlin.coroutines.await import io.vertx.kotlin.coroutines.dispatcher -import kotlinx.coroutines.CoroutineExceptionHandler -import kotlinx.coroutines.DelicateCoroutinesApi -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch +import kotlinx.coroutines.* import kotlinx.coroutines.slf4j.MDCContext import mu.KotlinLogging import kotlin.coroutines.AbstractCoroutineContextElement @@ -100,13 +97,12 @@ open class HttpRouterBuilder(private val vertx: Vertx, return context.dispatcher() + VertxRoutingContext(routingContext) + MDCContext() + exceptionHandler() } - @OptIn(DelicateCoroutinesApi::class) private fun registerCall(method: HttpMethod, path: String, handler: HttpServerHandler, filter: HttpServerFilter?) { underlying.route(method, path).handler { routingContext -> val request = HttpServerRequest(routingContext.request(), routingContext) val context = Vertx.currentContext() - GlobalScope.launch(createContext(routingContext)) { + CoroutineScope(createContext(routingContext)).launch { val response = filter?.let { it(request, handler) } ?: handler(request) val vertxResponse = routingContext.response()