Kotlin quickstart
Add the Gradle dependency and build your first JSON endpoint on the JVM or Kotlin/Native.
Build a Kotlin HTTP service
Add ktServe to a Kotlin/JVM app on JDK 21, or to a Kotlin Multiplatform source set targeting Linux x86-64, Linux ARM64 or Apple Silicon macOS.
Add the Gradle dependency
repositories { mavenCentral() }
dependencies {
implementation("codes.draeger:ktserve:0.4.0")
}
Register a JSON route
import codes.draeger.ktserve.json
import codes.draeger.ktserve.serve
fun main() = serve(port = 8080) {
get("/status") { json(mapOf("status" to "ok")) }
}
Start your application, then check the response from another terminal.
curl -fsS http://127.0.0.1:8080/status