Search code examples
kotlinnettyktor

How does Netty know about the application class / application configuration?


Given this code from Ktor server project generator:

fun main(args: Array<String>) {
    io.ktor.server.netty.EngineMain.main(args)
}

fun Application.module() {
    configureSerialization()
    configureSockets()
    configureRouting()
}

How does Netty know about the application configuration that is not passed into it? How is Application.module() called?


Solution

  • The module method can be determined by an FQN specified in the configuration file. By default, the application.conf or the application.yaml file is loaded. You can check out the resources directory for one of these files. You can find more information in the documentation.