← ClaudeAtlas

kotlin-ktorlisted

Use when building Ktor 3.x HTTP servers. Covers install blocks for ContentNegotiation, StatusPages, CORS, and WebSockets, JWT verifier configuration, Koin DI wiring, routing DSL, and testApplication integration tests including authenticated routes.
Mixard/fable-pack · ★ 1 · AI & Automation · score 74
Install: claude install-skill Mixard/fable-pack
# Ktor 3.x Server Patterns Ktor apps are configured as `Application` extension functions installing plugins, with routes as `Route` extension functions. Keep routes thin; push logic to services injected via Koin. ## Entry point and module ```kotlin fun main() { embeddedServer(Netty, port = 8080, module = Application::module).start(wait = true) } fun Application.module() { configureSerialization() configureAuthentication() configureStatusPages() configureCORS() configureDI() configureRouting() } ``` ## Routing DSL ```kotlin fun Application.configureRouting() { routing { userRoutes() authRoutes() } } fun Route.userRoutes() { val userService by inject<UserService>() // Koin route("/users") { get { call.respond(userService.getAll()) } get("/{id}") { val id = call.parameters["id"] ?: return@get call.respond(HttpStatusCode.BadRequest, "Missing id") val user = userService.getById(id) ?: return@get call.respond(HttpStatusCode.NotFound) call.respond(user) } post { val request = call.receive<CreateUserRequest>() call.respond(HttpStatusCode.Created, userService.create(request)) } delete("/{id}") { val id = call.parameters["id"] ?: return@delete call.respond(HttpStatusCode.BadRequest, "Missing id") if (userService.delete(id)) call.respond(