ktorio/ktor


Framework for quickly creating connected applications in Kotlin with minimal effort

https://ktor.io

License: Apache-2.0

Language: Kotlin

Keywords: async, asynchronous, kotlin, web, web-framework


Ktor

Official JetBrains project Download TeamCity Build GitHub License

Ktor is a framework for quickly creating web applications in Kotlin with minimal effort.

import io.ktor.server.netty.*
import io.ktor.routing.*
import io.ktor.application.*
import io.ktor.http.*
import io.ktor.response.*
import io.ktor.server.engine.*

fun main(args: Array<String>) {
    embeddedServer(Netty, 8080) {
        routing {
            get("/") {
                call.respondText("Hello, world!", ContentType.Text.Html)
            }
        }
    }.start(wait = true)
}
  • Runs embedded web server on localhost:8080
  • Installs routing and responds with Hello, world! when receiving GET http request for root path

Principles

Unopinionated

Ktor Framework doesn't impose a lot of constraints on what technology a project is going to use – logging, templating, messaging, persistent, serializing, dependency injection, etc. Sometimes it may be required to implement a simple interface, but usually it is a matter of writing a transforming or intercepting function. Features are installed into application using unified interception mechanism which allows building arbitrary pipelines.

Ktor Application can be hosted in any servlet container with Servlet 3.0+ API support such as Tomcat, or standalone using Netty or Jetty. Support for other hosts can be added through the unified hosting API.

Ktor APIs are mostly functions calls with lambdas. Thanks to Kotlin DSL capabilities, code looks declarative. Application composition is entirely developer's choice – with functions or classes, using dependency injection framework or doing it all manually in main function.

Asynchronous

Ktor pipeline machinery and API is utilising Kotlin coroutines to provide easy-to-use asynchronous programming model without making it too cumbersome. All host implementations are using asynchronous I/O facilities to avoid thread blocking.

Testable

Ktor application can be hosted in a special test environment, which emulates to some extent web server without actually doing any networking. It provides easy way to test an application without mocking too much stuff, and still achieve good performance while validating application calls. Integration tests with real embedded web server are of course possible, too.

Documentation

Please visit ktor.io for Quick Start and detailed explanations of features, usage and machinery.

  • Getting started with Gradle
  • Getting started with Maven
  • Getting started with IDEA

Inspirations

Kotlin web frameworks such as Wasabi and Kara, which are currently deprecated.

Reporting Security Vulnerabilities

If you find a security vulnerability in Ktor, we kindly request that instead of using our public issue tracker, you instead reach out to the JetBrains security team via our responsible disclosure process.

Project Statistics

Sourcerank 15
Repository Size 13.7 MB
Stars 5,932
Forks 444
Watchers 156
Open issues 449
Dependencies 1
Contributors 74
Tags 99
Created
Last updated
Last pushed

Top Contributors See all

Sergey Mashkov Ilya Ryzhenkov Leonid Stashevsky Carlos Ballesteros Velasco Vsevolod Tolstopyatov spand jeiea David Sommerich Roman Elizarov Hadi Hariri Markus M. May Camden Jonathan Leitschuh Daniel Mischler Tobias Erdle Júlio Cesar Bueno Cotta Maxim Logunov Daniel Douglas Soyka Fred Deschenes kosiakk

Packages Referencing this Repo

io.ktor:ktor-client-mock-jvm
Ktor is a framework for quickly creating web applications in Kotlin with minimal effort.
Latest release 1.2.4 - Updated - 5.93K stars
io.ktor:ktor-http-cio-jvm
Ktor is a framework for quickly creating web applications in Kotlin with minimal effort.
Latest release 1.2.3 - Updated - 5.93K stars
io.ktor:ktor-websockets
Ktor is a framework for quickly creating web applications in Kotlin with minimal effort.
Latest release 1.2.3 - Updated - 5.93K stars
io.ktor:ktor-client-ios
Framework for quickly creating connected applications in Kotlin with minimal effort
Latest release 1.0.1 - Updated - 5.93K stars
io.ktor:ktor-client-jackson
Ktor is a framework for quickly creating web applications in Kotlin with minimal effort.
Latest release 1.2.5 - Updated - 5.93K stars
io.ktor:ktor-client-json
Ktor is a framework for quickly creating web applications in Kotlin with minimal effort.
Latest release 1.2.3 - Updated - 5.93K stars
io.ktor:ktor-utils-js
Framework for quickly creating connected applications in Kotlin with minimal effort
Latest release 1.0.0 - Updated - 5.93K stars
io.ktor:ktor-http-ios
Framework for quickly creating connected applications in Kotlin with minimal effort
Latest release 1.0.0 - Updated - 5.93K stars
io.ktor:ktor-http
Framework for quickly creating connected applications in Kotlin with minimal effort
Latest release 1.0.0 - Updated - 5.93K stars
io.ktor:ktor-http-jvm
Framework for quickly creating connected applications in Kotlin with minimal effort
Latest release 1.0.0-rc - Published - 5.93K stars
io.ktor:ktor-server-host-common
Framework for quickly creating connected applications in Kotlin with minimal effort
Latest release 1.0.0-rc - Published - 5.93K stars
io.ktor:ktor-http-cio
Framework for quickly creating connected applications in Kotlin with minimal effort
Latest release 1.0.0-rc - Published - 5.93K stars
io.ktor:ktor-client-core
Ktor is a framework for quickly creating web applications in Kotlin with minimal effort.
Latest release 1.2.4 - Updated - 5.93K stars
io.ktor:ktor-server-core
Ktor is a framework for quickly creating web applications in Kotlin with minimal effort.
Latest release 1.1.3 - Updated - 5.93K stars
io.ktor:ktor-utils
Ktor is a framework for quickly creating web applications in Kotlin with minimal effort.
Latest release 1.1.3 - Updated - 5.93K stars
io.ktor:ktor-client-core-iosarm32
Ktor is a framework for quickly creating web applications in Kotlin with minimal effort.
Latest release 1.2.3 - Updated - 5.93K stars
io.ktor:ktor-http-js
Framework for quickly creating connected applications in Kotlin with minimal effort
Latest release 1.0.0 - Updated - 5.93K stars
io.ktor:ktor-locations
Ktor is a framework for quickly creating web applications in Kotlin with minimal effort.
Latest release 1.2.3 - Updated - 5.93K stars
io.ktor:ktor-gson
Framework for quickly creating connected applications in Kotlin with minimal effort
Latest release 1.0.0-rc - Published - 5.93K stars
io.ktor:ktor-utils-jvm
Framework for quickly creating connected applications in Kotlin with minimal effort
Latest release 1.0.0 - Updated - 5.93K stars

Recent Tags See all

1.2.5 September 27, 2019
1.3.0-beta-1 September 11, 2019
1.2.4 September 02, 2019
1.2.4 September 02, 2019
1.2.3 August 01, 2019
1.2.3-1.3.50-eap-5 July 26, 2019
1.2.3-rc July 23, 2019
1.2.3-rc July 23, 2019
1.2.2 June 20, 2019
1.2.1-1.3.40-eap-67 June 05, 2019
1.2.1 May 27, 2019
1.2.1 May 27, 2019
1.2.0 May 14, 2019
1.2.0-rc2 May 08, 2019
1.2.0-rc April 30, 2019

Something wrong with this page? Make a suggestion

Last synced: 2019-04-16 14:56:03 UTC

Login to resync this repository