Configuration

Configuration is data

Every value below is typed and read at startup. The framework sections start from their defaults, then `.env`, then the files in src/config/.

APP_NAMEdust demo
APP_ENVproduction
APP_DEBUGfalse
APP_URLhttps://demo.dustapp.dev
SESSION_DRIVERMemory
SESSION_LIFETIME2h
CACHE_STOREmemory
CACHE_PREFIXdust_demo_cache_
QUEUE_CONNECTIONsync
MAIL_MAILERlog
MAIL_FROM_ADDRESShello@example.com
CORS_CREDENTIALSfalse
CORS_ALLOWED_ORIGINSOnly(["https://demo.dustapp.dev", "https://dustapp.dev"])

The demo's own section

Unlike the framework sections, this one belongs to the application. It is declared in src/config/services.rs and arrives in the handler as Section<Demo>.

DEMO_GREETINGConfiguration is data
DEMO_SIGNATUREthe dust demo
DEMO_CACHE_TTL1m 30s

The section

#[derive(Clone, Debug, Section)]
pub struct Demo {
    #[env("DEMO_GREETING", default = "Hello from a configuration file")]
    pub greeting: String,

    #[env("DEMO_SIGNATURE", default = "the dust demo")]
    pub signature: String,

    #[env("DEMO_CACHE_TTL", seconds, default = 60)]
    pub cache_ttl: ExactDuration,
}

Change a value in .env or in the environment, restart, and the page shows the new one. The configuration guide covers the precedence and the fields.