use std::env;
#[derive(Debug, Clone)]
pub struct AppConfig {
pub cdn_host: String,
pub port: String,
}
impl AppConfig {
pub fn from_env() -> Self {
let cdn_host = env::var("CDN_HOST").unwrap_or_else(|_| "http://localhost".to_string());
let port = env::var("PORT").unwrap_or_else(|_| "80".to_string());
AppConfig { cdn_host, port }
}
pub fn base_url(&self) -> String {
if self.cdn_host.contains("localhost") {
format!("{}:{}", self.cdn_host, self.port)
} else {
self.cdn_host.to_string()
}
}
}