Fernando Sanchez (Perraco Labs)
06/20/2024, 5:52 PMGlobalScope
should be avoided due to its lack of structured concurrency, what is the best practice for achieving this? I was thinking of creating a scope in the route, but is there a better way to implement this?
fun Route.exampleRoute() {
get("/example") {
launch {
// This coroutine should continue running even after the response is sent
delay(1000)
println("Coroutine finished")
}
call.respondText("Request handled")
}
}
Stylianos Gakis
06/20/2024, 6:57 PM