https://kotlinlang.org logo
#ktor
Title
# ktor
j

Jgafner

08/01/2021, 3:45 PM
Hi Small question about development mode : Is it possible to let ktor decide which modules to load based on development mode ? If not is it possible with a custom property in the conf like in the example: https://ktor.io/docs/configurations.html#custom-property ? Thanks
a

Aleksei Tirman [JB]

08/01/2021, 3:56 PM
Is it possible to let ktor decide which modules to load based on development mode ?
No. The best thing you can do is to wrap a module's code with a check for the
developmentMode
or custom property condition. Here is an example:
Copy code
embeddedServer(Netty, applicationEngineEnvironment {
    connector {
        port = 7070
    }

    module {
        if (developmentMode) {
            routing {
                get("/") {
                    call.respondText { "You will see it in the development mode" }
                }
            }
        }
    }
}).start()
j

Jgafner

08/01/2021, 4:01 PM
Thanks @Aleksei Tirman [JB] - do you know it possible to pass which hocon file to use in the command line ? or maybe some feature like spring config profiles? so we can set some of the configuration to be enable in certain cases ? Thanks again
a

Aleksei Tirman [JB]

08/01/2021, 4:03 PM
You can use
-config
CLI argument to specify the path to a HOCON file.
j

Jgafner

08/01/2021, 4:04 PM
thanks
a

Aleksei Tirman [JB]

08/01/2021, 4:04 PM
or maybe some feature like spring config profiles?
I don't know about such a feature.