Migrate to config v0.12.0
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
0a518ab331
commit
84f4aa9be3
@ -18,21 +18,16 @@ pub struct Settings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Settings {
|
impl Settings {
|
||||||
#[deprecated]
|
|
||||||
pub fn new() -> Result<Self, ConfigError> {
|
|
||||||
Self::load()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn load() -> Result<Self, ConfigError> {
|
pub fn load() -> Result<Self, ConfigError> {
|
||||||
let mut config = Config::new();
|
Config::builder()
|
||||||
config
|
.add_source(File::with_name("hoc.toml").required(false))
|
||||||
.merge(File::with_name("hoc.toml").required(false))?
|
.add_source(Environment::with_prefix("hoc"))
|
||||||
.merge(Environment::with_prefix("hoc"))?
|
|
||||||
.set_default("repodir", "./repos")?
|
.set_default("repodir", "./repos")?
|
||||||
.set_default("cachedir", "./cache")?
|
.set_default("cachedir", "./cache")?
|
||||||
.set_default("workers", 4)?
|
.set_default("workers", 4)?
|
||||||
.set_default("port", 8080)?
|
.set_default("port", 8080)?
|
||||||
.set_default("host", "0.0.0.0")?;
|
.set_default("host", "0.0.0.0")?
|
||||||
config.try_into()
|
.build()?
|
||||||
|
.try_deserialize()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user