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)]
|
#[derive(Deserialize, Serialize, Debug, Clone)]
|
||||||
pub struct WebsiteConfig {
|
pub struct WebsiteConfig {
|
||||||
pub label: String,
|
pub label: String,
|
||||||
pub base: String,
|
pub base: Option<String>,
|
||||||
pub endpoints: Vec<EndpointConfig>,
|
pub endpoints: Vec<EndpointConfig>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
extern crate actix;
|
extern crate actix;
|
||||||
extern crate actix_web;
|
extern crate actix_web;
|
||||||
|
extern crate chrono;
|
||||||
extern crate env_logger;
|
extern crate env_logger;
|
||||||
extern crate reqwest;
|
extern crate reqwest;
|
||||||
extern crate ron;
|
extern crate ron;
|
||||||
|
@ -7,7 +8,6 @@ extern crate serde;
|
||||||
extern crate tokio;
|
extern crate tokio;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate tera;
|
extern crate tera;
|
||||||
extern crate chrono;
|
|
||||||
|
|
||||||
mod config;
|
mod config;
|
||||||
mod handlers;
|
mod handlers;
|
||||||
|
@ -68,8 +68,7 @@ fn main() {
|
||||||
tokio::spawn(
|
tokio::spawn(
|
||||||
Interval::new_interval(Duration::from_secs(config.refresh_time))
|
Interval::new_interval(Duration::from_secs(config.refresh_time))
|
||||||
.for_each(move |_| {
|
.for_each(move |_| {
|
||||||
let state = Arc::clone(&clone_state);
|
update_state(Arc::clone(&clone_state));
|
||||||
update_state(state);
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
.map_err(|_| ()),
|
.map_err(|_| ()),
|
||||||
|
|
|
@ -86,8 +86,12 @@ fn get_result(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_url(base: &String, path: &String, port: Option<u16>) -> Result<String, UrlError> {
|
fn get_url(base: &Option<String>, path: &String, port: Option<u16>) -> Result<String, UrlError> {
|
||||||
let mut url = Url::parse(base)?.join(path)?;
|
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) {
|
if let Err(e) = url.set_port(port) {
|
||||||
println!("{:?}", e);
|
println!("{:?}", e);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue