Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon

Kotlin based framework, Ktor 1.0, released with features like sessions, metrics, call logging and more

Save for later
  • 3 min read
  • 21 Nov 2018

article-image

In October, Kotlin’s framework Ktor 1.0 beta was released. It delivered high performance and an idiomatic API. Yesterday Ktor 1.0 was released as the first major version of the Kotlin-based framework. Ktor, a JetBrains project, builds asynchronous servers and clients in connected systems coroutines and also delivers good runtime performance. Ktor version 1.0 includes few essential features like sessions, authentication, JSON serialization, popular template engines, Web sockets, metrics, and many others.

Ktor 1.0 feature highlights


Ktor 1.0 has two main parts, namely, HTTP server framework and a multiplatform HTTP client.

HTTP server framework


The HTTP server framework built on Netty, Jetty and Java servlets runs on the JVM. Netty and Jetty, the lightweight engines make the processing faster as it helps in receiving connections within a second. It is container-friendly and can easily be embedded into desktop/Android applications. It could be run in an application server, for example,Tomcat.

Multiplatform HTTP client


Multiplatform HTTP client is asynchronous and is built using coroutines and IO primitives which are responsible for driving the server. It is implemented as a multiplatform library. The client is used for building asynchronous microservice architectures and for connecting all the backend functionalities into asynchronous pipelines. The multiplatform HTTP client makes it easy to retrieve data without blocking application execution on mobile devices and web pages uniformly. It supports JVM, JS, Android and iOS.

Features

  • Ktor’s built-in support for serving static content is useful for serving style sheets, scripts, images, etc.
  • Ktor provides a mechanism for constructing URLs and reading the parameters to create routes in a typed way.
  • Ktor’s Metrics feature helps in configuring the Metrics to get useful information about the server and the requests.
  • It also has a mechanism called session useful for persisting data between different HTTP requests. Session also helps servers to keep a piece of information associated with the client during a sequence of HTTP requests and responses.
  • Ktor’s Compression feature is used for compressing outgoing content using gzip, deflate or custom encoder. This helps in reducing the size of the response.
  • Ktor provides Call Logging feature which is used for logging client requests.
  • Ktor 1.0 introduced WebSockets mechanism to keep a bi-directional, real-time and ordered connection between the server and the client.

Major improvements

Unlock access to the largest independent learning library in Tech for FREE!
Get unlimited access to 7500+ expert-authored eBooks and video courses covering every tech area you can think of.
Renews at €18.99/month. Cancel anytime
  • Ktor 1.0 comes with improved performance and documentation
  • It uses Kotlin 1.3.10
  • Ktor 1.0 has fixed client response cancelation via receive<Unit>() and response.cancel()
  • In Ktor 1.0 there are improvements to test client and mock engine
  • The DevelopmentEngine has been renamed to EngineMain
  • There is an improved serialization client feature

Bug fixes

  • Fixes to Cookies dates, domains, and dupicate parameters processing.
  • Websocket session lifecycle has been fixed in Ktor 1.0
  • Timeouts in WebSockets have been fixed with jetty


To know more about this news, check out the announcement on Jetbrains blog.

Kotlin 1.3 released with stable coroutines, multiplatform projects and more

How to avoid NullPointerExceptions in Kotlin [Video]

Implementing Concurrency with Kotlin [Tutorial]