added should_err endpoint config option
This commit is contained in:
parent
18a95cb3cd
commit
57574993b6
3 changed files with 20 additions and 8 deletions
|
@ -8,6 +8,7 @@ pub struct EndpointConfig {
|
|||
pub code: Option<u16>,
|
||||
pub body: Option<String>,
|
||||
pub follow_redirects: Option<bool>,
|
||||
pub should_err: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug, Clone)]
|
||||
|
|
|
@ -33,7 +33,7 @@ pub type State = Arc<RwLock<QueryResults>>;
|
|||
fn main() {
|
||||
System::run(move || {
|
||||
let config = from_str::<Config>(
|
||||
&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();
|
||||
|
|
|
@ -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)),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue