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

Viewed 28

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.

1 Answers

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