Access the current tenant in a handler
Problem
In a multi-tenant app every query must run against the request's tenant pool.
Add the Tenant extractor to your handler. The resolver maps the request host/subdomain to an Org and hands you a tenant-scoped pool via t.pool().
use rustango::extractors::Tenant;
async fn dashboard(t: Tenant) -> Result<Json<Vec<Project>>, RustangoError> {
// Every query is automatically scoped to this tenant's database.
let projects = Project::objects().fetch(t.pool()).await?;
Ok(Json(projects))
}
Storage modes
Database-mode gives each tenant its own DB (any backend); schema-mode shares one Postgres DB via SET search_path. The extractor abstracts both.