made base parameter optional
This commit is contained in:
parent
c83190ada6
commit
0f4ca23655
3 changed files with 9 additions and 6 deletions
|
@ -12,7 +12,7 @@ pub struct EndpointConfig {
|
|||
#[derive(Deserialize, Serialize, Debug, Clone)]
|
||||
pub struct WebsiteConfig {
|
||||
pub label: String,
|
||||
pub base: String,
|
||||
pub base: Option<String>,
|
||||
pub endpoints: Vec<EndpointConfig>,
|
||||
}
|
||||
|
||||
|
|
|
@ -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(|_| ()),
|
||||
|
|
|
@ -86,8 +86,12 @@ fn get_result(
|
|||
}
|
||||
}
|
||||
|
||||
fn get_url(base: &String, path: &String, port: Option<u16>) -> Result<String, UrlError> {
|
||||
let mut url = Url::parse(base)?.join(path)?;
|
||||
fn get_url(base: &Option<String>, path: &String, port: Option<u16>) -> Result<String, UrlError> {
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue