kotlin-ktor
from pluginagentmarketplace/custom-plugin-kotlin
Kotlin Development Plugin
3 stars1 forksUpdated Jan 5, 2026
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-kotlin --skill kotlin-ktorSKILL.md
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
| Issue | Resolution |
|---|---|
| 404 for valid route | Order specific routes before wildcards |
| JSON not parsed | Install ContentNegotiation plugin |
Usage
Skill("kotlin-ktor")
Repository Stats
Stars3
Forks1
LicenseOther