module
Noir::TreeSitterKotlinKtorRouteExtractor
Overview
Tree-sitter-backed Ktor DSL route extractor.
Walks the canonical Ktor server idiom:
routing {
get("/x") { ... }
route("/api") {
post("/items") { val item = call.receive < Item > () }
}
authenticate("auth-jwt") {
get("/profile") { ... }
}
}
Recognises:
- Verb DSL calls —
get/post/put/delete/patch/head/optionswith a string-literal path argument and a trailing lambda body. route("/x") { ... }blocks contributing to the path prefix.authenticate("realm") { ... }blocks acting as transparent wrappers (no prefix change). Tagging is handled elsewhere; we just descend so wrapped routes are still discovered.routing { ... }andapplication.routing { ... }entry points.- Inside each verb's lambda body:
call.receive<T>()→bodyparameter typedTasjsoncall.parameters["name"]→nameparameter asquerycall.request.headers["name"]→nameparameter asheader
Not covered yet (out of scope for this first cut):
- Resource-based routing (
get<Resource> { ... }). - Type-safe routing via
@Resource. install(plugin) { ... }plugin scoping that affects routing.
Extended Modules
Defined in:
miniparsers/kotlin_ktor_route_extractor_ts.crConstant Summary
-
HTTP_VERB_NAMES =
{"get" => "GET", "post" => "POST", "put" => "PUT", "delete" => "DELETE", "patch" => "PATCH", "head" => "HEAD", "options" => "OPTIONS"} -
PASSTHROUGH_NAMES =
Set {"routing", "authenticate", "rateLimit", "install", "intercept", "host", "port"} -
Pass-through DSL calls — descend into their lambda body without changing the path prefix.
routingis the entry point;authenticatewraps a sub-tree behind an auth realm; the remaining names cover the common Ktor scoping helpers.