kotlin-ktor-patterns

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

Content Preview
---
name: kotlin-ktor-patterns
description: Ktor 服务器模式,包括路由 DSL、插件、身份验证、Koin DI、kotlinx.serialization、WebSockets 和 testApplication 测试。
origin: ECC
---

# Ktor 服务器模式

使用 Kotlin 协程构建健壮、可维护的 HTTP 服务器的综合 Ktor 模式。

## 何时启用

* 构建 Ktor HTTP 服务器
* 配置 Ktor 插件(Auth、CORS、ContentNegotiation、StatusPages)
* 使用 Ktor 实现 REST API
* 使用 Koin 设置依赖注入
* 使用 testApplication 编写 Ktor 集成测试
* 在 Ktor 中使用 WebSocket

## 应用程序结构

### 标准 Ktor 项目布局

```text
src/main/kotlin/
├── com/example/
│   ├── Application.kt           # Entr
How to Use

Recommended: Install to project (local)

mkdir -p .claude/skills
curl -o .claude/skills/kotlin-ktor-patterns.md \
  https://raw.githubusercontent.com/affaan-m/everything-claude-code/main/docs/zh-CN/skills/kotlin-ktor-patterns/SKILL.md

Skill is scoped to this project only. Add .claude/skills/ to your .gitignoreif you don't want to commit it.

Alternative: Clone full repo

git clone https://github.com/affaan-m/everything-claude-code

Then reference at docs/zh-CN/skills/kotlin-ktor-patterns/SKILL.md

Related Skills