fix: smart var replace in client too
This commit is contained in:
parent
5670b8b67a
commit
c29c91a7b9
1 changed files with 9 additions and 13 deletions
|
@ -1,4 +1,4 @@
|
||||||
use crate::ext::FillableFromEnvironment;
|
use crate::ext::{FillError, FillableFromEnvironment};
|
||||||
|
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
|
#[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize)]
|
||||||
|
@ -16,21 +16,17 @@ pub struct ClientConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FillableFromEnvironment for ClientConfig {
|
impl FillableFromEnvironment for ClientConfig {
|
||||||
fn fill(mut self, env: &toml::Table) -> Self {
|
fn fill(mut self, env: &toml::Table) -> Result<Self, FillError> {
|
||||||
let vars = Self::default_vars(env);
|
let vars = Self::default_vars(env);
|
||||||
|
|
||||||
for (k, v) in vars {
|
if let Some(ref base) = self.base {
|
||||||
let k_var = format!("${{{k}}}");
|
self.base = Some(Self::replace(base.clone(), &vars)?);
|
||||||
|
|
||||||
if let Some(base) = self.base {
|
|
||||||
self.base = Some(base.replace(&k_var, &v));
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(user_agent) = self.user_agent {
|
|
||||||
self.user_agent = Some(user_agent.replace(&k_var, &v));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
self
|
if let Some(ref user_agent) = self.user_agent {
|
||||||
|
self.user_agent = Some(Self::replace(user_agent.clone(), &vars)?);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue