diff --git a/src/config.rs b/src/config.rs index 45e8144..fa50c91 100644 --- a/src/config.rs +++ b/src/config.rs @@ -12,7 +12,7 @@ pub struct EndpointConfig { #[derive(Deserialize, Serialize, Debug, Clone)] pub struct WebsiteConfig { pub label: String, - pub base: String, + pub base: Option, pub endpoints: Vec, } diff --git a/src/main.rs b/src/main.rs index 9bdf02c..cf529b0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ extern crate actix; extern crate actix_web; +extern crate chrono; extern crate env_logger; extern crate reqwest; extern crate ron; @@ -7,7 +8,6 @@ extern crate serde; extern crate tokio; #[macro_use] extern crate tera; -extern crate chrono; mod config; mod handlers; @@ -68,8 +68,7 @@ fn main() { tokio::spawn( Interval::new_interval(Duration::from_secs(config.refresh_time)) .for_each(move |_| { - let state = Arc::clone(&clone_state); - update_state(state); + update_state(Arc::clone(&clone_state)); Ok(()) }) .map_err(|_| ()), diff --git a/src/updater.rs b/src/updater.rs index 268e447..6ad490d 100644 --- a/src/updater.rs +++ b/src/updater.rs @@ -86,8 +86,12 @@ fn get_result( } } -fn get_url(base: &String, path: &String, port: Option) -> Result { - let mut url = Url::parse(base)?.join(path)?; +fn get_url(base: &Option, path: &String, port: Option) -> Result { + let mut url = if let Some(base) = base { + Url::parse(base)?.join(path)? + } else { + Url::parse(path)? + }; if let Err(e) = url.set_port(port) { println!("{:?}", e); }