Handlers & routing
Write async handlers and compose them into a router.
rustango builds on axum. #[rustango::main] sets up the Tokio runtime + tracing; you compose a Router and hand it to manage::Cli. Handlers are async functions that take extractors and return anything IntoResponse — Json, Html, or RustangoResult<T>.
async fn list_posts(State(pool): State<Pool>) -> Result<Json<Vec<Post>>, RustangoError> {
Ok(Json(Post::objects().fetch(&pool).await?))
}
let app = Router::new().route("/posts", get(list_posts)).with_state(pool);
Named URLs
Register routes with register_url!("blog:detail", "/blog/<id>") and build links with reverse(...) — no hardcoded paths.