I am trying to build up an application from Ktor which eventually should be executed via a fatjar. A fatjar allows the use of arguments like the following one:
java -jar myApp.jar XXXXX YYYYY
I know how to get the XXXXX
in the main module (by using simple args[0]
) but I have troubles to get that values in the Application modules.
I would like to do something like that:
fun main(args: Array<String>) {
val port = System.getenv("PORT")?.toInt() ?: 8080
val status = args[0]
embeddedServer(Netty, port = port, module = (Application::mainModule())).start(wait = true)
}
fun Application.mainModule() {
routing {
get("/status") {
call.respondText(
<status variable from main function>,
contentType = ContentType.Text.Html
)
}
}
}