Application main

An application instance is the main unit of a Ktor application. It is the starting point of our application. A request (which can be an HTTP, HTTP/2, or Socket request) comes in the application and is converted to an ApplicationCall. It then goes through a pipeline that contains one or more previously installed interceptors; these provide certain functionalities such as routing, compression, and many more.

The ApplicationCall provides access to two main properties:

  • ApplicationRequest: This corresponds to the incoming request
  • ApplicationResponse: This corresponds to the outgoing response

It also provides some useful functions to help respond to client requests. 

Let's look at our main Application.kt file:

    /** * Starting ...

Get Kotlin Blueprints now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.