SKILL

kotlin-ktor-patterns

Ktor server patterns, including routing DSL, plugins, authentication, Koin DI, kotlinx.serialization, WebSockets, and testApplication testing.

Machine translation
Read the original Chinese text

Ktor 服务器模式,包括路由 DSL、插件、身份验证、Koin DI、kotlinx.serialization、WebSockets 和 testApplication 测试。

Target: Target not categorized. Automatically collected · unverified.

Excerpt from the author’s documentation

Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.

Read the original Chinese text

Topics in the source

  • Ktor 服务器模式
  • 何时启用
  • 应用程序结构
  • 标准 Ktor 项目布局
  • 应用程序入口点
  • 路由 DSL
  • 基本路由
  • 使用认证路由组织路由

使用 Kotlin 协程构建健壮、可维护的 HTTP 服务器的综合 Ktor 模式。 构建 Ktor HTTP 服务器 配置 Ktor 插件(Auth、CORS、ContentNegotiation、StatusPages) 使用 Ktor 实现 REST API 使用 Koin 设置依赖注入 使用 testApplication 编写 Ktor 集成测试 在 Ktor 中使用 WebSocket | 模式 | 描述 | |---------|-------------| | route("/path") { get { } } | 使用 DSL 进行路由分组 | | call.receive () | 反序列化请求体 | | call.respond(status, body) | 发送带状态的响应 | | call.parameters["id"] | 读取路径参数 | | call.request.queryParameters["q"] | 读取查询参数 | | install(Plugin) { } | 安装并配置插件 | | authenticate("name") { } | 使用身份验证保护路由 | | by inject () | Koin 依赖注入 | | testApplication { } | 集成测试 | 记住:Ktor 是围绕 Kotlin 协程和 DSL 设计的。保持路由精简,将逻辑推送到服务层,并使用 Koin 进行依赖注入。使用 testApplication 进行测试以获得完整的集成覆盖。

Source repository
affaan-m/ECC
Source file
docs/zh-CN/skills/kotlin-ktor-patterns/SKILL.md
Fixed revision
d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Read the complete original documentation ↗

Sources and evidence

This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.

Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T15:01:42.407Z.

Categories are inferred from names, descriptions and paths. They do not establish compatibility.

License and attribution

MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.

Original license ↗

Synchronization, copying and user-reported success do not mark a resource as runtime-tested.

Limitations and notes

  • Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.