diff --git a/core/lib/src/config/mod.rs b/core/lib/src/config/mod.rs index f99c444b..e134b05a 100644 --- a/core/lib/src/config/mod.rs +++ b/core/lib/src/config/mod.rs @@ -58,8 +58,9 @@ //! //! An application that wants to use Rocket's defaults for [`Config`], but not //! its configuration sources, while allowing the application to be configured -//! via an `App.toml` file and `APP_` environment variables, can be structured -//! as follows: +//! via an `App.toml` file that uses top-level keys as profiles (`.nested()`) +//! and `APP_` environment variables as global overrides (`.global()`), can be +//! structured as follows: //! //! ```rust //! # #[macro_use] extern crate rocket; @@ -83,8 +84,8 @@ //! fn rocket() -> _ { //! let figment = Figment::from(rocket::Config::default()) //! .merge(Serialized::defaults(Config::default())) -//! .merge(Toml::file("App.toml")) -//! .merge(Env::prefixed("APP_")); +//! .merge(Toml::file("App.toml").nested()) +//! .merge(Env::prefixed("APP_").global()); //! //! rocket::custom(figment) //! .mount("/", routes![/* .. */]) diff --git a/site/guide/9-configuration.md b/site/guide/9-configuration.md index 937a1d6a..22ad22f4 100644 --- a/site/guide/9-configuration.md +++ b/site/guide/9-configuration.md @@ -302,7 +302,9 @@ fn rocket() -> _ { More involved, consider an application that wants to use Rocket's defaults for [`Config`], but not its configuration sources, while allowing the application to -be configured via an `App.toml` file and `APP_` environment variables: +be configured via an `App.toml` file that uses top-level keys as profiles +(`.nested()`) and `APP_` environment variables as global overrides +(`.global()`): ```rust # #[macro_use] extern crate rocket; @@ -327,8 +329,8 @@ impl Default for Config { fn rocket() -> _ { let figment = Figment::from(rocket::Config::default()) .merge(Serialized::defaults(Config::default())) - .merge(Toml::file("App.toml")) - .merge(Env::prefixed("APP_")); + .merge(Toml::file("App.toml").nested()) + .merge(Env::prefixed("APP_").global()); rocket::custom(figment) .mount("/", routes![/* .. */])