← Tous les modèles

Coroutines qui ne bloquent jamais, routes typées, kotlinx.serialization partout.

Constitution — Ktor service

Version 1.0.0 · Ratified 2026-11-10

These principles hold for every spec, plan and task of the project. A spec may add rules; it never weakens these.

  1. Coroutines that never block. Handlers are suspend functions that call only suspending clients. Blocking JDBC or file I/O runs inside withContext(Dispatchers.IO), and runBlocking outside main and tests fails the review.

  2. Structured concurrency. Concurrent work is launched in the call’s scope with coroutineScope or async, never in GlobalScope. Cancellation propagates and CancellationException is never swallowed.

  3. Typed routes. Routes are declared with the Resources plugin as @Resource classes, so paths and parameters are checked at compile time. Path and query values are not read by string name from call.parameters.

  4. kotlinx.serialization everywhere. Request and response bodies are @Serializable data classes handled by ContentNegotiation with kotlinx.serialization. No Jackson or Gson on the same paths, and unknown keys in requests are rejected unless the spec says otherwise.

  5. Errors through StatusPages. Domain errors are sealed classes or typed exceptions mapped to status codes and one error body in the StatusPages plugin. Handlers do not build error responses by hand.

  6. Tested with testApplication. Every route has a test using testApplication with the real module and fake dependencies, covering success and invalid input. Modules are installed through functions that take their dependencies, so tests can pass fakes.