Hello folks, :wave::skin-tone-4: When it comes to...
# ktor
h
Hello folks, 👋🏽 When it comes to migrating from Ktor 2.2.x to 3.x do we have any guide on how we should be handling the scenario in which we buildApplicationEnvironment? For example:
Copy code
val builder = ApplicationEnvironmentBuilder()
    builder.developmentMode = false
    builder.connector {
        port = 8082
    }

    builder.module {}
Do you have any example how the above should be handled on Ktor 3.x? I checked the migration guide, but it only says about renaming classes.
a
Here is the same configuration made with Ktor 3.0.0:
Copy code
val server = embeddedServer(Netty, serverConfig(applicationEnvironment()) {
    developmentMode = true
    
    module {

    }
}, configure = {
    connectors.add(EngineConnectorBuilder().apply {
        port = 8082
    })
})
h
Thanks so much for the quick response Aleksei. I'm a bit confused though. Is this how we should be the Application Environment now? I ended-up going with an implementation like that: Is that the same thing? I was skeptical about the
serverConfig
under
configure
.
Copy code
embeddedServer(Netty,
                configure = {
                    connector { port = 8080 }
                    serverConfig { developmentMode = false }
                },
                module = {
                    mainModule()
                }
            ).start(wait = false)
Based on what you shared my configuration seems a bit different. But is that valid?
a
The
serverConfig { developmentMode = false }
call creates an instance of the
ServerConfig
but this configuration isn't applied (has no effect) to the server.
h
Interesting. Thank you very much. I also suppose adding the change under configure would not have any effect either.
Copy code
configure = {
        configure = { connector { port = 8082 } },
            connector { port = 8082 }
            applicationEnvironment {
                serverConfig { developmentMode = false }
            }
        },
Anyway, I'll probably go with your approach if I ended-up needing to set developmentMode again. It seems that the tests that used to fail because that was not set are now passing. 🤷🏽