News

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

2 min read

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

  • 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.

Read Next

Kotlin 1.3 released with stable coroutines, multiplatform projects and more

How to avoid NullPointerExceptions in Kotlin [Video]

Implementing Concurrency with Kotlin [Tutorial]

Amrata Joshi

Share
Published by
Amrata Joshi

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago