mirror of https://github.com/rwf2/Rocket.git
Mimic Rocket's config in custom providers example.
This commit is contained in:
parent
de1cffba46
commit
edc91f65b7
|
@ -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![/* .. */])
|
||||
|
|
|
@ -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![/* .. */])
|
||||
|
|
Loading…
Reference in New Issue