Hi everyone, I’m Ktor 2 server we were able to se...
# ktor
p
Hi everyone, I’m Ktor 2 server we were able to set the
parentCoroutineContext
from the
ApplicationEnvironment.parentCoroutineContext
. In ktor3 ownership was changed to `Application`; however, now the property is
val
. Let’s say I want my server to run on a certain coroutine. Should I wrap the
embeddedServer().start()
call in a
withContext
? Or is there another way to accomplish this?
a
You can specify
parentCoroutineContext
using an overload of the
embeddedServer
method which accepts
ServerConfig
:
Copy code
embeddedServer(Netty, serverConfig {
    parentCoroutineContext = Dispatchers.Default
    module {
        routing {
            get {
                call.respondText("Hello World!")
            }
        }
    }
}).start(wait = true)
gratitude thank you 1
p
Thanks I missed that one!