added option to not follow redirects
This commit is contained in:
parent
0f4ca23655
commit
e88efdae56
2 changed files with 9 additions and 2 deletions
|
@ -7,6 +7,7 @@ pub struct EndpointConfig {
|
|||
pub port: Option<u16>,
|
||||
pub code: Option<u16>,
|
||||
pub body: Option<String>,
|
||||
pub follow_redirects: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug, Clone)]
|
||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
|||
State,
|
||||
};
|
||||
use chrono::prelude::*;
|
||||
use reqwest::{Client, Url, UrlError};
|
||||
use reqwest::{Client, RedirectPolicy, Url, UrlError};
|
||||
|
||||
pub fn update_state(state: State) {
|
||||
let new_statuses = { Some(update_status(&state.read().unwrap().config)) };
|
||||
|
@ -15,12 +15,18 @@ pub fn update_state(state: State) {
|
|||
}
|
||||
|
||||
pub fn update_status(config: &Config) -> Vec<StatusGroup> {
|
||||
let client = Client::new();
|
||||
let mut results: Vec<StatusGroup> = Vec::with_capacity(config.websites.len());
|
||||
|
||||
for website_conf in &config.websites {
|
||||
let mut group = Vec::with_capacity(website_conf.endpoints.len());
|
||||
for endpoint in &website_conf.endpoints {
|
||||
let mut client_builder = Client::builder();
|
||||
|
||||
if let Some(false) = endpoint.follow_redirects {
|
||||
client_builder = client_builder.redirect(RedirectPolicy::none());
|
||||
}
|
||||
|
||||
let client = client_builder.build().unwrap();
|
||||
group.push(get_result(website_conf, &client, endpoint));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue