Using Kotlin extension functions, we can make the definition and installation of our service's routes easier to read and maintain. To do this, perform the following steps:
- Start by creating a new package under the /src directory, and name that package routes:
- Now, we'll create a new file within this package named /src/routes/route_root.kt.
- Without route_root.kt, we will define an extension function on the Route type to define how our root endpoint route should be handled:
// route_root.ktfun Route.root() { get("/") { call.respondText("Hello World", ContentType.Text.Plain) }}
You'll notice that we've ...