Agent skill · software engineering · affaan-m

kotlin-ktor-patterns

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

Why this skill is useful

Provides specific Ktor patterns and integration examples that enhance the AI's ability to generate Ktor applications effectively.

What it needs

Requires kotlin installed locally. About 6k tokens when loaded. Last updated 2026-08-06. 238,342 stars on the source repository.

What this skill does

Ktor 服务器模式 使用 Kotlin 协程构建健壮、可维护的 HTTP 服务器的综合 Ktor 模式。 何时启用 构建 Ktor HTTP 服务器 配置 Ktor 插件(Auth、CORS、ContentNegotiation、StatusPages) 使用 Ktor 实现 REST API 使用 Koin 设置依赖注入 使用 testApplication 编写 Ktor 集成测试 在 Ktor 中使用 WebSocket 应用程序结构 标准 Ktor 项目布局 应用程序入口点 路由 DSL 基本路由 使用认证路由组织路由 内容协商与序列化 kotlinx.serialization 设置 可序列化模型 自定义序列化器 身份验证 JWT 身份验证 认证路由 状态页(错误处理) CORS 配置 Koin 依赖注入 模块定义 在路由中使用 Koin 用于测试的 Koin 请求验证 WebSocket testApplication 测试 基本路由测试 测试认证路由 配置 application.yaml 读取配置 快速参考:Ktor 模式 模式 描述 --------- ------------- route("/path") { get { } } 使用 DSL 进行路由分组 call.receive<T>() 反序列化请求体 call.respond(status, body) 发送带状态的响应 call.parameters["id"] 读取路径参数 call.request.queryParameters["q"] 读取查询参数 install(Plugin) { } 安装并配置插件 authenticate("name") { } 使用身份验证保护路由 by inject<T>() Koin 依赖注入 testApplication { } 集成测试 记住:Ktor 是围绕 Kotlin 协程和 DSL 设计的。保持路由精简,将逻辑推送到服务层,并使用 Koin 进行依赖注入。使用 testApplication 进行测试以获得完整的集成覆盖。

How to use it

Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:

@skills affaan-m/kotlin-ktor-patterns--ec1f51

View the source on GitHub

Browse the @skills marketplace