Rustango docs
← Rustango 0.48

Cookbook

Chapter 1 — Project shape & manage commands

Everything a project needs — scaffolding, migrations, users, config — runs through one CLI: cargo run -- <verb>. Here's the verb list (cargo run --…

Chapter 2 — Models & schema

Models live in src/apps/blog/models.rs. Live tests against docker PG in tests/cookbook_chapter02_models.rs. Run with DATABASEURL=... cargo test --test…

Chapter 3 — ORM

13 live recipes against the Author / Post fixture from Chapter 2. Run with DATABASEURL=... cargo test --test cookbookchapter03orm -- --test-threads=1.

Chapter 4 — Migrations

5 live recipes against a live database verifying the migration lifecycle. Run with DATABASEURL=... cargo test --test cookbookchapter04migrations --…

Chapter 5 — Multi-tenancy

One comprehensive live test that provisions two tenants in schema mode, then exercises every resolver against the seeded registry. Run with…

Chapter 6 — Auth + permissions

7 live tests on the password / API-key / JWT / permission primitives. No DB needed — pure crypto. Run with cargo test --test cookbookchapter06auth.

Chapter 7 — Forms + serializer

6 tests covering ModelFormFor<T> parse/fromjson/error aggregation/ bound-validation/null handling/insert-query emission. No DB needed. Run with cargo test…

Chapter 8 — Admin

Two parts: in-process router smoke + a real-browser playwright session. What it looks like. These are live captures of the auto-admin served by the…

Chapter 9b — Template views (Django-shape CBVs)

API: `template_views::ListView`, `template_views::DetailView`, `template_views::CreateView`, `template_views::UpdateView`, `template_views::DeleteView`.

Chapter 9 — ViewSets / DRF / OpenAPI

4 live tests against ViewSet::formodel(...).router(...) mounted in-process. Run with DATABASEURL=... cargo test --test cookbookchapter09viewsets --…

Chapter 9d — tenant_router for tenancy projects

5 live tests against ViewSet::formodel(...).tenantrouter(...) mounted under a real TenantContext extension with header-based tenant resolution. Run with…

Chapter 9e — Searching with the HTTP QUERY method (RFC 10008)

3 tests, no DB — one product-search handler serving both GET and QUERY from the same code. Run with cargo test --test cookbookchapter09equerysearch.

Chapter 10 — Templates + static

3 tests on the Tera template surface that the admin (Chapter 8) + operator console use. No DB needed. Run with cargo test --test…

Chapter 11 — Async / IO / extensions

Run with cargo test --test cookbookchapter11extensions.

Chapter 12 — Tri-dialect + cross-cutting

3 live tests against a docker MySQL 8.0 container, exercising the same cookbook model that PG tests use through the dialect-agnostic Pool + savepool /…

Chapter 13 — SQLite backend

SQLite is a third dialect alongside Postgres and MySQL. Same Pool enum, same ORM surface — the macro emits FromRow<SqliteRow> + LoadRelatedSqlite + a…

Chapter 14 — Doing less work

This chapter collects the shortcuts that collapse a multi-step setup or config write into a single call. Each recipe below maps a 4–5 step chain to one…

Chapter 15 — Tenant admin URL scoping

The tenant admin claims only an explicit set of routes; every other URL falls through to your API router's .fallback(). That is what lets a CMS-style…

Chapter 16 — Every feature on every backend

"Tri-dialect everywhere": every framework surface runs on PostgreSQL, MySQL 8+, and SQLite out of the box. Concretely:

Known backend limitations

ddl::createconstraintssqlwithdialect emits ALTER TABLE … ADD CONSTRAINT FOREIGN KEY, which SQLite's parser rejects (FK constraints must be inline at…

Chapter 17 — MCP server: expose tools to AI agents

The mcp feature turns a rustango app into a Model Context Protocol server: external AI agents authenticate as tenant-scoped identities, are granted skills…

Chapter 18 — Internationalization (i18n)

6 tests, no DB — rustango::i18n::Translator, Django's gettext family in Rust. Run with cargo test --test cookbookchapter18i18n.

Chapter 19 — Rate limiting

2 tests, no DB — rustango::ratelimit::RateLimitLayer, a token-bucket middleware. Run with cargo test --test cookbookchapter19ratelimit.

Chapter 20 — Health checks

cargo test --test cookbookchapter20health. /health is liveness (always 200 {"status":"ok"}, probes nothing — point your load balancer here). /ready is…

Chapter 21 — Secrets manager

2 tests, no DB — rustango::secrets::Secrets, a pluggable secrets backend. Run with cargo test --test cookbookchapter21secrets.