Skip to main content

Module server

Module server 

Source
Expand description

Django-style runserver — [server::Builder] owns every line of boilerplate every tenancy app would otherwise rewrite (DB pool, resolver chain, host dispatch, operator console, bind + serve).

Module itself is unconditional so the bi-dialect single-pool server::AppBuilder is available without the tenancy feature. The full multi-tenant [server::Builder] is gated inside the module on tenancy. rustango::server — Django-style runserver builder.

Owns every line of boilerplate that’s identical across tenancy apps: connect to DATABASE_URL, build TenantPools, mount the resolver chain, host-dispatch apex → operator console / subdomain → tenant admin + user routes, bind + serve.

use rustango::server::Builder;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    tracing_subscriber::fmt().init();
    Builder::from_env().await?
        .admin_show_only(["author", "post"])
        .api(my_app::urls::api())
        .seed_with(|pools, registry, registry_url| async move {
            my_app::seed::run(&pools, &registry, &registry_url).await
        })
        .await?
        .serve("0.0.0.0:8080").await
}

Structs§

AppBuilder
Single-pool builder. Use Self::from_env (reads DATABASE_URL) or Self::from_pool (you supply the pool) to construct.