6 ms·
Kotlin really shines when it comes to async programming. This is some code I wrote using Vert.x with Kotlin extensions : router.get("/api/article/:id").cor
by volgar1x 7y ago
Kotlin really shines when it comes to async programming. This is some code I wrote using Vert.x with Kotlin extensions :
router.get("/api/article/:id").coroutineHandler { ctx ->
val news = newsRepository.get(ctx.pathParam("id")) // no need for await
?: return ctx.respondText(404, "Not Found") // can still use basic code constructs
ctx.respondJson(200, jsonObjectOf("news" to news)) // actually an extension method i wrote
}