feat: replace vars in urls with environment variables

jank af implementation but works?
This commit is contained in:
əlemi 2023-06-08 12:04:24 +02:00
parent 048ee833f0
commit 5bf55e1384
Signed by: alemi
GPG key ID: A4895B84D311642C

View file

@ -40,12 +40,21 @@ pub fn requests(root: Items) -> Vec<RequestClass> {
}
pub fn url(req: &RequestClass) -> String {
match &req.url {
let mut base_url = match &req.url {
Some(Url::String(x)) => x.clone(),
Some(Url::UrlClass(UrlClass { raw: Some(raw) , .. })) => raw.clone(),
// TODO compose UrlClass
_ => "".into(),
};
for (k, v) in std::env::vars() {
let key = format!("{{{{{}}}}}", k);
if base_url.contains(&key) {
base_url = base_url.replace(&key, &v);
}
}
base_url
}
pub async fn send(req: RequestClass) -> reqwest::Result<reqwest::Response> {