diff --git a/src/config.rs b/src/config.rs index 764788a..273af62 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,6 +8,7 @@ pub struct EndpointConfig { pub code: Option, pub body: Option, pub follow_redirects: Option, + pub should_err: Option, } #[derive(Deserialize, Serialize, Debug, Clone)] diff --git a/src/main.rs b/src/main.rs index cf529b0..5d09087 100644 --- a/src/main.rs +++ b/src/main.rs @@ -33,7 +33,7 @@ pub type State = Arc>; fn main() { System::run(move || { let config = from_str::( - &read_to_string("./endstat_conf.ron").expect("Could not find config file"), + &read_to_string("./endstat_conf.ron").expect("finding ./endstat_conf.ron"), ) .unwrap(); let bind_addr = config.bind_address.clone(); diff --git a/src/updater.rs b/src/updater.rs index 105e6d2..423dc1b 100644 --- a/src/updater.rs +++ b/src/updater.rs @@ -3,7 +3,7 @@ use crate::{ handlers::{EndpointStatus, StatusGroup}, State, }; -use chrono::prelude::*; +use chrono::prelude::Utc; use reqwest::{Client, RedirectPolicy, Url, UrlError}; use std::time::Duration; @@ -84,12 +84,23 @@ fn get_result( error, } } - Err(e) => EndpointStatus { - status: 2, - location: url, - endpoint: label, - error: Some(format!("{}", e)), - }, + Err(e) => { + if let Some(true) = endpoint.should_err { + EndpointStatus { + status: 0, + location: url, + endpoint: label, + error: None, + } + } else { + EndpointStatus { + status: 2, + location: url, + endpoint: label, + error: Some(format!("{}", e)), + } + } + } } }