October 2021
Intermediate to advanced
500 pages
16h 23m
English
In this chapter, you used Ktor as an HTTP client to consume data from the flight endpoints. Ktor also has another trick up its sleeve: It is also a web server framework for the JVM. In fact, the kotlin-book.bignerdranch.com/2e endpoints you used were hosted with Ktor.
If you are interested in spinning up your own server using Kotlin and Ktor, check out its official website at ktor.io. For reference, here is a simplified version of the main function for the server you have been interacting with in this chapter:
fun main() = embeddedServer(Netty, port = 8080) { routing { get("/") { call.respondRedirect( url = "https://bignerdranch.com/books/" ) } route("2e") { get("flight") { delay(5000) call.respond( ...Read now
Unlock full access