kotlin-ktor

Ktor framework - routing, authentication, WebSockets

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "kotlin-ktor" with this command: npx skills add pluginagentmarketplace/custom-plugin-kotlin/pluginagentmarketplace-custom-plugin-kotlin-kotlin-ktor

Kotlin Ktor Skill

Build production-ready backends with Ktor.

Topics Covered

Routing

fun Application.module() {
    install(ContentNegotiation) { json() }
    routing {
        route("/api/v1") {
            get("/users") { call.respond(userService.findAll()) }
            get("/users/{id}") {
                val id = call.parameters["id"]?.toLongOrNull()
                    ?: throw BadRequestException("Invalid ID")
                call.respond(userService.findById(id) ?: throw NotFoundException())
            }
        }
    }
}

JWT Authentication

install(Authentication) {
    jwt("auth") {
        verifier(JWT.require(Algorithm.HMAC256(secret)).build())
        validate { credential ->
            if (credential.payload.getClaim("userId").asString().isNotEmpty())
                UserPrincipal(credential.payload)
            else null
        }
    }
}

authenticate("auth") { userRoutes() }

Testing

@Test
fun `GET users returns list`() = testApplication {
    application { module() }
    client.get("/api/v1/users").apply {
        assertThat(status).isEqualTo(HttpStatusCode.OK)
    }
}

Troubleshooting

IssueResolution
404 for valid routeOrder specific routes before wildcards
JSON not parsedInstall ContentNegotiation plugin

Usage

Skill("kotlin-ktor")

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

kotlin-compose

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

kotlin-android

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

kotlin-testing

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

kotlin-fundamentals

No summary provided by upstream source.

Repository SourceNeeds Review