Skip to content

Instantly share code, notes, and snippets.

@toantran-ea
Last active November 30, 2019 09:16
Show Gist options
  • Save toantran-ea/219e962bc15b9aa4ac71d36b7c271ba6 to your computer and use it in GitHub Desktop.
Save toantran-ea/219e962bc15b9aa4ac71d36b7c271ba6 to your computer and use it in GitHub Desktop.
init application routing
package com.example.demo
/* ktlint-disable no-wildcard-imports */
import io.ktor.application.Application
import io.ktor.application.call
import io.ktor.application.install
import io.ktor.features.CallLogging
import io.ktor.features.DefaultHeaders
import io.ktor.response.respond
import io.ktor.routing.get
import io.ktor.routing.post
import io.ktor.routing.routing
// Entry Point of the application as defined in resources/application.conf.
// @see https://ktor.io/servers/configuration.html#hocon-file
fun Application.main() {
install(DefaultHeaders)
install(CallLogging)
routing {
get("/") {
call.respond("Hello World 111 !!")
}
get("entries") {
call.respond("Hello World 222 !!")
}
post("entries") {
call.respond("Hello World 333 !!")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment