kotlin-ktor-patterns

Configure Ktor HTTP servers with routing, plugins, Koin DI, and serialization.

1|Updated Apr 7, 2026
One-click install
npx skills add https://github.com/Michae2xl/claude-skills-michael --skill kotlin-ktor-patterns-michae2xl
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlin-ktor-patterns
Source: https://github.com/Michae2xl/claude-skills-michael/tree/main/skills/kotlin-ktor-patterns
Command: npx skills add https://github.com/Michae2xl/claude-skills-michael --skill kotlin-ktor-patterns-michae2xl

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires ktor-server-netty, koin-core, kotlinx-serialization-json, and includes scripts (resource) and references (resource) and assets (resource) components.

What problem does it solve?

This Skill equips you with comprehensive patterns for building robust and maintainable HTTP servers using Ktor.

Core Features & Use Cases

  • Routing DSL: Configure routes and handle different HTTP methods.
  • Plugins: Use Ktor plugins like Auth, CORS, and StatusPages.
  • Koin DI: Set up dependency injection for your application.
  • Serialization: Work with kotlinx.serialization for content negotiation.
  • WebSockets: Implement real-time communication with WebSockets.
  • Testing: Use testApplication for integration testing of Ktor applications.
  • Use Case: Build a REST API server with authentication, status pages, and CORS configuration.

Quick Start

Run the application with the provided entry point to start the Ktor server.

Frequently Asked Questions about kotlin-ktor-patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up dependency injection in a Kotlin Ktor server?

To set up dependency injection in a Kotlin Ktor server, you use the Koin framework. This approach configures your application modules and injects dependencies directly into your routing and plugin classes.

What is the best way to configure routing and plugins like CORS and Auth in Ktor?

The best way to configure routing and Ktor plugins like CORS, Auth, and StatusPages is by using the Ktor Routing DSL. This method structures your HTTP server endpoints and handles cross-cutting concerns efficiently.

Do I need kotlinx.serialization installed for content negotiation in Ktor?

Yes, you need kotlinx.serialization installed for content negotiation in Ktor. It handles JSON serialization and deserialization, allowing your HTTP server to seamlessly process incoming and outgoing request bodies.

How does WebSocket integration work for real-time communication in a Kotlin HTTP server?

WebSocket integration in a Kotlin HTTP server works by establishing persistent bidirectional connections. Ktor provides built-in WebSocket routing capabilities to facilitate real-time data exchange between the server and connected clients.

How do I write integration tests for my Ktor application?

You write integration tests for a Ktor application using the testApplication function. This allows you to spin up a test server, send HTTP requests to your configured routes, and assert responses without deploying.

Why does my Ktor server return unformatted errors when an exception is thrown?

Your Ktor server returns unformatted errors because StatusPages plugin is not configured. Implementing StatusPages catches thrown exceptions and formats standardized HTTP error responses before returning them to the client.