Home > Mobile >  How can I tell from code if development mode is active in Ktor?
How can I tell from code if development mode is active in Ktor?

Time:09-08

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)
  • Related