Bertram Kirsch
03/11/2021, 7:50 AMclass SomeApp {
fun Application.main(testing: Boolean = false) {
install(ContentNegotiation) {
gson {
setPrettyPrinting()
}
}
routing {
underpants() // serves context "/underpants"
staticResources() // serves root context "/"
groot() // serves context "/groot"
}
}
}
// Route for static context
fun Routing.staticResources() {
// Serves frontend resources embedded in application jar
static("/") {
defaultResource("index.html", "web-resource")
resources("web-resource")
}
}
fun Routing.underpants(
) {
route("/underpants") {
get {
val map: HashMap<Int, String> = hashMapOf(1 to "Collect underpants.", 2 to "?", 3 to "Profit!")
call.respond(map)
}
}
}
fun Routing.groot(
) {
route("/groot") {
get {
val map: HashMap<Int, String> = hashMapOf(1 to "I", 2 to "am", 3 to "Groot!")
call.respond(map)
}
}
}
Rustam Siniukov
03/11/2021, 12:18 PMBertram Kirsch
03/11/2021, 1:25 PMJoost Klitsie
03/12/2021, 4:02 PM