Treat env vars set to "" as if they were unset (#73)

* Treat env vars set to "" as if they were unset

* Bump version to 0.4.4
This commit is contained in:
Daniel Sockwell 2020-01-07 13:07:54 -05:00 committed by GitHub
parent 07e8776090
commit bf529a901b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 7 deletions

2
Cargo.lock generated
View File

@ -404,7 +404,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "flodgatt"
version = "0.4.3"
version = "0.4.4"
dependencies = [
"criterion 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)",
"dotenv 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)",

View File

@ -1,7 +1,7 @@
[package]
name = "flodgatt"
description = "A blazingly fast drop-in replacement for the Mastodon streaming api server"
version = "0.4.3"
version = "0.4.4"
authors = ["Daniel Long Sockwell <daniel@codesections.com", "Julian Laubstein <contact@julianlaubstein.de>"]
edition = "2018"

View File

@ -117,13 +117,21 @@ macro_rules! from_env_var {
$body
}
pub fn maybe_update(self, var: Option<&String>) -> Self {
if let Some(value) = var {
Self(Self::inner_from_str(value).unwrap_or_else(|| {
match var {
Some(empty_string) if empty_string.is_empty() => Self::default(),
Some(value) => Self(Self::inner_from_str(value).unwrap_or_else(|| {
crate::err::env_var_fatal($env_var, value, $allowed_values)
}))
} else {
self
})),
None => self,
}
// if let Some(value) = var {
// Self(Self::inner_from_str(value).unwrap_or_else(|| {
// crate::err::env_var_fatal($env_var, value, $allowed_values)
// }))
// } else {
// self
// }
}
}
};