ktorio/ktor
Fork: 1063 Star: 13046 (更新于 2024-11-19 21:24:36)
license: Apache-2.0
Language: Kotlin .
Framework for quickly creating connected applications in Kotlin with minimal effort
最后发布版本: 3.0.0 ( 2024-10-10 17:46:01)
Ktor 是一个轻松构建联网应用(web 应用、 HTTP 服务、 移动应用以及浏览器应用)的框架。 现代的联网应用需要异步化来提供最佳的用户体验,而 Kotlin 协程为此提供了极其简便的方式。
Ktor is an asynchronous framework for creating microservices, web applications and more. Written in Kotlin from the ground up.
First add the dependency to your project:
repositories {
mavenCentral()
}
dependencies {
implementation("io.ktor:ktor-server-netty:$ktor_version")
}
Then create an Application
and install some features:
import io.ktor.server.netty.*
import io.ktor.server.routing.*
import io.ktor.server.application.*
import io.ktor.http.*
import io.ktor.server.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)
}
You also can use Ktor 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 on
localhost:8080
- Installs routing and responds with
Hello, 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 a transforming or intercepting function. Features are installed into the application using a unified interception mechanism which allows building arbitrary pipelines.
Ktor Applications 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, the code looks declarative. Application composition is entirely up to the developer's choice – with functions or classes, using dependency injection framework 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 asynchronous programming model without making it too cumbersome. All host implementations are using asynchronous I/O facilities to avoid thread blocking.
Testable
Ktor applications can be hosted in a special test environment, which emulates a web server to some extent 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. Running integration tests with a real embedded web server are of course possible, too.
JetBrains Product
Ktor is an official JetBrains product and is primarily developed by the team at JetBrains, with contributions from the community.
Documentation
Please visit ktor.io for Quick Start and detailed explanations of features, usage and machinery.
Reporting Issues / Support
Please use our issue tracker for filing feature requests and bugs. If you'd like to ask a question, we recommend StackOverflow where members of the team monitor frequently.
There is also community support on the Kotlin 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 via our responsible disclosure process.
Inspirations
Kotlin web frameworks such as Wasabi and Kara, which are currently deprecated.
Contributing
Please see the contribution guide and the Code of conduct before contributing.
最近版本更新:(数据更新于 2024-10-28 12:54:40)
2024-10-10 17:46:01 3.0.0
2024-10-03 20:44:21 3.0.0-rc-2
2024-09-10 22:19:40 3.0.0-rc-1
2024-07-16 23:20:54 3.0.0-beta-2
2024-06-21 16:04:56 2.3.12
2024-05-09 15:14:09 2.3.11
2024-04-08 23:00:24 2.3.10
2024-03-04 22:11:13 2.3.9
2024-01-31 23:58:01 2.3.8
2023-12-07 22:09:00 2.3.7
主题(topics):
async, asynchronous, kotlin, web, web-framework
ktorio/ktor同语言 Kotlin最近更新仓库
2024-11-19 23:12:26 jellyfin/jellyfin-androidtv
2024-11-18 20:14:29 gkd-kit/gkd
2024-11-11 21:37:35 FooIbar/EhViewer
2024-11-01 20:22:27 EhViewer-NekoInverter/EhViewer
2024-11-01 16:15:30 tiann/KernelSU
2024-10-27 19:26:53 salvogiangri/KnoxPatch