Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Framework for quickly creating connected applications in Kotlin with minimal effort

License

NotificationsYou must be signed in to change notification settings

ktorio/ktor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ktor logo

Official JetBrains projectMaven CentralKotlinSlack channelGitHub LicenseContribute with Gitpod

Ktor is an asynchronous framework for creating microservices, web applications and more. Written in Kotlin from theground up.

First add the dependency to your project:

repositories {    mavenCentral()}dependencies {    implementation("io.ktor:ktor-server-netty:$ktor_version")}

Then create anApplication and install some features:

importio.ktor.server.netty.*importio.ktor.server.routing.*importio.ktor.server.application.*importio.ktor.http.*importio.ktor.server.response.*importio.ktor.server.engine.*funmain(args:Array<String>) {    embeddedServer(Netty,8080) {        routing {            get("/") {                call.respondText("Hello, world!",ContentType.Text.Html)            }        }    }.start(wait=true)}

You also can useKtor Gradle Plugin to configure bom, run tasks and deployment:

plugins {    id("io.ktor.plugin") version"3.0.0"}dependencies {    implementation("io.ktor:ktor-server-netty")}

To run the created application, execute:

./gradlew run
  • Runs embedded web server onlocalhost:8080
  • Installs routing and responds withHello, world! when receiving a GET http request for the root path

Start using Ktor

Build your first Kotlin HTTP or RESTful application using Ktor:start.ktor.io

Principles

Unopinionated

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

Ktor Applications can be hosted in any servlet container with Servlet 3.0+ API support such as Tomcat, orstandalone 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, the code looks declarative.Application composition is entirely up to the developer's choice – with functions or classes, using dependency injectionframework or doing it all manually in the main function.

Asynchronous

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

Testable

Ktor applications can be hosted in a special test environment, which emulates a web server to someextent without actually doing any networking. It provides easy way to test an application without mockingtoo much stuff, and still achieve good performance while validating application calls. Running integration tests with arealembedded web server are of course possible, too.

JetBrains Product

Ktor is an officialJetBrains product and is primarily developed by the team at JetBrains, withcontributionsfrom the community.

Documentation

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

  • Getting started withGradle
  • Getting started withMaven
  • Getting started withIDEA

Reporting Issues / Support

Please useour issue tracker for filing feature requests and bugs. Ifyou'd like to ask a question, we recommendStackOverflow wheremembers of the team monitor frequently.

There is also community support on theKotlin Slack Ktor channel

Reporting Security Vulnerabilities

If you find a security vulnerability in Ktor, we kindly request that you reach out to the JetBrains security team viaourresponsible disclosure process.

Inspirations

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

Contributing

Please seethe contribution guide and theCode of conduct before contributing.


[8]ページ先頭

©2009-2025 Movatter.jp