embeddedServer(Netty, port = 8000) {
routing {
get ("/") {
call.respondText("Hello, world!")
}
}
}.start(wait = true)
}
Simple and fun
Create asynchronous client and server applications. Anything from microservices to multiplatform HTTP client apps in a simple way. Open Source, free, and fun!
Build Backend
The Ktor HTTP server offers features like powerful routing, a robust plugin system, and simple configuration. By leveraging kotlinx.coroutines and JetBrains’ tooling support, Ktor can enhance your backend development.
val client = HttpClient {
install(WebSockets)
}
client.ws("ws://example.com/ws") {
send(Frame.Text("Hello, world!"))
val frame = incoming.receive()
println("Received: $frame")
}
}
Create Client
The Ktor HTTP client simplifies sending requests, handling responses, and managing real-time communication with WebSockets and server-sent events (SSE).
Why Ktor?
Kotlin and Coroutines
Ktor is built from the ground up using Kotlin and Coroutines. You get to use a concise, multiplatform language, as well as the power of asynchronous programming with an intuitive imperative flow.
Lightweight and Flexible
Ktor allows you to use only what you need, and to structure your application the way you need it. In addition you can also extend Ktor with your own plugin very easily.
Built and backed by JetBrains
Brought to you by JetBrains, creators of IntelliJ IDEA, Kotlin, and more. Ktor is not only used by our customers, but also internally at JetBrains. In addition, you have top-notch tooling support!