Ktor 1.0 is here – Built from the ground up using coroutines

Share
  • November 20, 2018

We first learned about Ktor 1.0 beta with the release of Kotlin 1.3 but now it’s time to see the results of the team’s hard work!

Ktor 1.0 is here.

In case you haven’t heard the news, “Ktor is a Kotlin framework for building asynchronous servers and clients in connected systems. It is being created by the Kotlin team, and as such, it takes full advantage of the language in order to provide a great developer experience and excellent runtime performance.”

    DevOpsCon Whitepaper 2018

    Free: BRAND NEW DevOps Whitepaper 2018

    Learn about Containers,Continuous Delivery, DevOps Culture, Cloud Platforms & Security with articles by experts like Michiel Rook, Christoph Engelbert, Scott Sanders and many more.

With no further ado, let’s see what Ktor 1.0 brings.

Server – Provides a rich and easy-to-use extensibility mechanism, on top of which most of the built-in functionality is implemented. Third-party features look no different from the built-in ones. Out of the box, Ktor includes all the essential features like sessions, authentication, JSON serialization, popular template engines, Web sockets, metrics, and many others. It also supports a productive development workflow, with a fast start, automatic reloading, and easy-to-use facilities for writing unit and integration tests.

SEE ALSO: Kotlin 1.3 is out: Coroutines graduate to stable, plus betas for Kotlin/Native & Ktor 1.0

Client – Built using the same coroutines and IO primitives that drive the server. This makes it perfect for building asynchronous microservice architectures, connecting all the backend functionality into asynchronous pipelines. The client is implemented as a multiplatform library, which currently supports JVM, JS, Android, and iOS. This makes it possible to retrieve data on mobile devices and web pages in a uniform way, without blocking application execution or building complex chains of anonymous functions to handle successes or failures.

Tools – You can now select the features you need and get a fully working starter app with Ktor. This works both on the Web and via a plugin for IntelliJ IDEA.

Here’s how ‘hello world’ looks like:

fun main() {
    embeddedServer(Netty, port = 8080) {
        routing {
            get("/") {
                call.respondText("Hello World!")
            }
        }
    }.start(wait = true)
}

Getting started

Ktor is free and open-source and it’s available on GitHub. You can check out the quickstart guide here.

For more information on the tool, you can have a look at the extensive documentation for writing servers and clients here and here.

The post Ktor 1.0 is here – Built from the ground up using coroutines appeared first on JAXenter.

Source : JAXenter