I'm upgrading to ktor 3.x, and I used to programma...
# ktor
a
I'm upgrading to ktor 3.x, and I used to programmatically set
developmentMode
inside of
applicationEngineEnvironment
, but that no longer seems to be an option, anyone know how I can do it for ktor 3?
a
You can do it by passing an
ServerConfig
instance to the
embeddedServer
. Here is an example:
Copy code
fun Application.module() {
    routing {
        get {
            call.respondText { "okay" }
        }
    }
}

fun main() {
    embeddedServer(
        Netty,
        serverConfig {
            developmentMode = true
            module(Application::module)
         },
        configure = {
            connector { port = 12345 }
        }
    ).start(wait = true)
}
Also, I've created an issue to update the documentation.
a
strange, the overload it really wants me to use is this:
Copy code
public fun <TEngine : ApplicationEngine, TConfiguration : ApplicationEngine.Configuration> embeddedServer(
    factory: ApplicationEngineFactory<TEngine, TConfiguration>,
    environment: ApplicationEnvironment = applicationEnvironment(),
    configure: TConfiguration.() -> Unit = {},
    module: Application.() -> Unit = {}
): EmbeddedServer<TEngine, TConfiguration> {
    val applicationProperties = serverConfig(environment) {
        module(body = module)
    }
    return embeddedServer(factory, applicationProperties, configure)
}
I also see that some of the overloads that are extensions on
CoroutineScope
have other arguments that I'd like to use, such as
watchPaths
which doesn't seem to be present on the non-coroutinescope ones
ah ya so just not passing in the ApplicationEnvironment now gets me to the right overload
thank you