mirror of https://github.com/rwf2/Rocket.git
Default to production environment on non-debug builds.
This commit is contained in:
parent
19f59b1f9b
commit
f9a950d1c7
|
@ -84,8 +84,13 @@ impl Environment {
|
||||||
/// Returns a `BadEnv` `ConfigError` if `ROCKET_ENV` contains an invalid
|
/// Returns a `BadEnv` `ConfigError` if `ROCKET_ENV` contains an invalid
|
||||||
/// environment name.
|
/// environment name.
|
||||||
pub fn active() -> Result<Environment, ConfigError> {
|
pub fn active() -> Result<Environment, ConfigError> {
|
||||||
let env_str = env::var(CONFIG_ENV).unwrap_or(Development.to_string());
|
match env::var(CONFIG_ENV) {
|
||||||
env_str.parse().map_err(|_| ConfigError::BadEnv(env_str))
|
Ok(s) => s.parse().map_err(|_| ConfigError::BadEnv(s)),
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
_ => Ok(Development),
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
_ => Ok(Production),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a string with a comma-seperated list of valid environments.
|
/// Returns a string with a comma-seperated list of valid environments.
|
||||||
|
|
Loading…
Reference in New Issue