How can I tell from code if development mode is active in Ktor? I'd like to force login a test user when development mode is active to facilitate manual testing.
CodePudding user response:
You can access an application instance from a call object and then an environment object which has the developmentMode
property.
embeddedServer(Netty, port = 3000) {
routing {
get("/") {
println(call.application.environment.developmentMode)
}
}
}.start(wait = true)