Ktor’s shape, Rust’s stack
I write a lot of Kotlin and reach for Rust when safety and performance matter. What I kept missing on the server was Ktor’s developer experience: build an application, install what you need, describe routes in one place, and ship.
Churust is that shape on tokio + hyper + rustls. The framework owns the ergonomic layer (routing, extractors, plugins, config, limits) without reinventing HTTP parsing or TLS.
What’s inside
- Hybrid handlers: call style (
Call) or typed extractors (Path,Query,Json,State,Principal, and friends), mixed freely. Body consumers are last argument only, enforced by the compiler. install(plugin): middleware into a fixed phase order (Setup → Monitoring → Plugins → Call → Fallback), so composition stays deterministic.- Secure defaults: body and connection limits, timeouts (including slow loris aware header reads), security headers, panic isolation, strict path policy, safe cookie defaults.
- First party features: JSON, logging, CORS, auth (Bearer / Basic / JWT), rate limiting, compression, templates, Redis sessions, HTTP client, OpenAPI 3.1, WebSockets, static files, multipart, TLS, HTTP/2, and HTTP/3. All opt in via Cargo features.
- Lockstep crates: umbrella
churustplus core, macros, and plugins release on one version so the tree stays aligned.
Install
[dependencies]
churust = "0.3"
With the common plugin set and transports:
churust = { version = "0.3", features = ["full", "ws", "fs", "tls"] }
Minimal server
use churust::prelude::*;
#[churust::main]
async fn main() -> std::io::Result<()> {
Churust::server()
.port(8080)
.routing(|r| {
r.get("/", |_call: Call| async { "Hello from Churust 🌀" });
r.get("/users/{id}", |Path(id): Path<u64>| async move {
format!("user #{id}")
});
})
.start()
.await
}
Docs & source
| Resource | Link |
|---|---|
| User guide | davthecoder.github.io/Churust |
| API reference | docs.rs/churust |
| crates.io | crates.io/crates/churust |
| GitHub | github.com/davthecoder/Churust |
| Intro post | Introducing Churust |
Runnable examples in the repo: hello, api, chat, and static-example.
Frequently Asked Questions
What is Churust?
Churust is an open-source Rust web framework inspired by Kotlin’s Ktor. It provides a server builder, routing DSL, installable plugins, typed extractors, and secure-by-default configuration on top of tokio, hyper, and rustls.
Who is it for?
Backend developers who want a clear, approachable API in Rust, especially people coming from Ktor or other install plugin frameworks, without giving up typed extractors, modern HTTP, or production minded defaults.
Is it production-ready?
Version 0.3 is built for real services: limits, graceful shutdown, streaming, auth, sessions, broad tests, and lockstep releases. It is still pre-1.0, so pin the version and read the changelog before upgrading.
Where do I learn it?
Start with the user guide, then use docs.rs for types and the GitHub examples for full programs.
La forma de Ktor, la pila de Rust
Escribo mucho Kotlin y recurro a Rust cuando importan la seguridad y el rendimiento. Lo que echaba en falta en el servidor era la experiencia de desarrollo de Ktor: construir una aplicación, instalar lo que hace falta, describir las rutas en un solo sitio y publicar.
Churust es esa forma sobre tokio + hyper + rustls. El framework se queda la capa ergonómica (enrutado, extractores, plugins, configuración, límites) sin reinventar el análisis de HTTP ni TLS.
Qué incluye
- Manejadores híbridos: estilo llamada (
Call) o extractores tipados (Path,Query,Json,State,Principaly compañía), mezclados con libertad. Los consumidores del cuerpo solo pueden ir en el último argumento, y lo impone el compilador. install(plugin): el middleware entra en un orden de fases fijo (Setup → Monitoring → Plugins → Call → Fallback), así que la composición sigue siendo determinista.- Valores seguros por defecto: límites de cuerpo y de conexión, tiempos de espera (incluidas lecturas de cabeceras conscientes de slow loris), cabeceras de seguridad, aislamiento de pánicos, política estricta de rutas y cookies seguras por defecto.
- Funciones de primera parte: JSON, registro, CORS, autenticación (Bearer / Basic / JWT), limitación de tasa, compresión, plantillas, sesiones en Redis, cliente HTTP, OpenAPI 3.1, WebSockets, ficheros estáticos, multipart, TLS, HTTP/2 y HTTP/3. Todo es opcional mediante features de Cargo.
- Crates sincronizados: el paraguas
churustmás core, macros y plugins se publican en una sola versión, para que el árbol siga alineado.
Instalación
[dependencies]
churust = "0.3"
Con el conjunto habitual de plugins y de transportes:
churust = { version = "0.3", features = ["full", "ws", "fs", "tls"] }
Servidor mínimo
use churust::prelude::*;
#[churust::main]
async fn main() -> std::io::Result<()> {
Churust::server()
.port(8080)
.routing(|r| {
r.get("/", |_call: Call| async { "Hello from Churust 🌀" });
r.get("/users/{id}", |Path(id): Path<u64>| async move {
format!("user #{id}")
});
})
.start()
.await
}
Documentación y código
| Recurso | Enlace |
|---|---|
| Guía de usuario | davthecoder.github.io/Churust |
| Referencia de la API | docs.rs/churust |
| crates.io | crates.io/crates/churust |
| GitHub | github.com/davthecoder/Churust |
| Artículo de presentación | Presentación de Churust |
Ejemplos ejecutables en el repositorio: hello, api, chat y static-example.
Preguntas frecuentes
¿Qué es Churust?
Churust es un framework web de código abierto en Rust, inspirado en Ktor, de Kotlin. Ofrece un constructor de servidor, una DSL de enrutado, plugins instalables, extractores tipados y una configuración segura por defecto, sobre tokio, hyper y rustls.
¿Para quién es?
Para quien desarrolla backend y quiere una API clara y accesible en Rust, sobre todo quien llega desde Ktor u otros frameworks de plugins instalables, sin renunciar a extractores tipados, a HTTP moderno ni a unos valores por defecto pensados para producción.
¿Está listo para producción?
La versión 0.3 está hecha para servicios reales: límites, apagado ordenado, streaming, autenticación, sesiones, pruebas amplias y publicaciones sincronizadas. Sigue siendo anterior a la 1.0, así que fija la versión y lee el registro de cambios antes de actualizar.
¿Por dónde se aprende?
Empieza por la guía de usuario, usa después docs.rs para los tipos y los ejemplos de GitHub para programas completos.
