Reputation: 1344
I am a little bit confused with this line of hello world kotr code written in Kotlin.
fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
what is code is doing here in the above line?
full code for reference
fun main(args: Array<String>): Unit = io.ktor.server.netty.EngineMain.main(args)
@Suppress("unused") // Referenced in application.conf
@kotlin.jvm.JvmOverloads
fun Application.module(testing: Boolean = false) {
val client = HttpClient(Apache) {
}
routing {
get("/") {
call.respondText("HELLO WORLD! from KTOR", contentType = ContentType.Text.Plain)
}
}
}
Upvotes: 1
Views: 128
Reputation: 8457
It's calling the main loop of the netty servlet so it starts handling incoming http requests
It's equivalent to
fun main(args: Array<String>){
io.ktor.server.netty.EngineMain.main(args)
}
Or
import io.ktor.netty.EngineMain
fun main(args: Array<String>){
EngineMain.main(args)
}
So you could say it literally starts the server, otherwise it would be your good-old CLI program with a main function
Upvotes: 3