Compare commits
No commits in common. "5aa57864d75ba2b83f812002535aa0cefc31a5b6" and "18a95cb3cdbc52e27b177f61afc2fe4b905a79dc" have entirely different histories.
5aa57864d7
...
18a95cb3cd
6 changed files with 17 additions and 48 deletions
|
@ -24,9 +24,8 @@
|
|||
label: "Even more stuff!",
|
||||
endpoints: [
|
||||
(label: "Or expect different reponse codes (like 418)", endpoint: "http://error418.net/", code: 418),
|
||||
(label: "Or response checking!", endpoint: "http://urlecho.appspot.com/echo", body: "None"),
|
||||
(label: "Or bodies!", endpoint: "http://urlecho.appspot.com/echo", body: "None"),
|
||||
(label: "Or both!", endpoint: "http://urlecho.appspot.com/echo?status=503&Content-Type=text%2Fhtml&body=None", body: "None", code: 503),
|
||||
(label: "Or expect the endpoint to fail entirely!", endpoint: "http://lol.arpa", should_err: true),
|
||||
],
|
||||
),
|
||||
(
|
||||
|
@ -34,7 +33,7 @@
|
|||
endpoints:[
|
||||
(label: "The code doesn't match!", endpoint: "http://example.com/", code: 204),
|
||||
(label: "The body doesn't match!", endpoint: "http://example.com/", body: "asdf"),
|
||||
(label: "Here's an error:", endpoint: "https://some-invalid-website.arpa")
|
||||
(label: "Here's an error", endpoint: "https://some-invalid-website.arpa")
|
||||
]
|
||||
),
|
||||
]
|
||||
|
|
|
@ -8,7 +8,6 @@ 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)]
|
||||
|
|
|
@ -15,35 +15,6 @@ pub struct EndpointStatus {
|
|||
pub error: Option<String>,
|
||||
}
|
||||
|
||||
impl EndpointStatus {
|
||||
pub fn ok(location: String, endpoint: String) -> Self {
|
||||
EndpointStatus {
|
||||
status: 0,
|
||||
location,
|
||||
endpoint,
|
||||
error: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn warn(location: String, endpoint: String, error: Option<String>) -> Self {
|
||||
EndpointStatus {
|
||||
status: 1,
|
||||
location,
|
||||
endpoint,
|
||||
error,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn error(location: String, endpoint: String, error: Option<String>) -> Self {
|
||||
EndpointStatus {
|
||||
status: 2,
|
||||
location,
|
||||
endpoint,
|
||||
error,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Debug)]
|
||||
pub struct StatusGroup {
|
||||
pub label: String,
|
||||
|
|
|
@ -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("finding ./endstat_conf.ron"),
|
||||
&read_to_string("./endstat_conf.ron").expect("Could not find config file"),
|
||||
)
|
||||
.unwrap();
|
||||
let bind_addr = config.bind_address.clone();
|
||||
|
@ -51,7 +51,7 @@ fn main() {
|
|||
let clone_state = Arc::clone(&state);
|
||||
|
||||
HttpServer::new(move || {
|
||||
let tera = compile_templates!("./templates/**/*");
|
||||
let tera = compile_templates!(concat!(env!("CARGO_MANIFEST_DIR"), "/templates/**/*"));
|
||||
let state = Arc::clone(&state);
|
||||
|
||||
App::new()
|
||||
|
|
|
@ -3,7 +3,7 @@ use crate::{
|
|||
handlers::{EndpointStatus, StatusGroup},
|
||||
State,
|
||||
};
|
||||
use chrono::prelude::Utc;
|
||||
use chrono::prelude::*;
|
||||
use reqwest::{Client, RedirectPolicy, Url, UrlError};
|
||||
use std::time::Duration;
|
||||
|
||||
|
@ -77,19 +77,19 @@ fn get_result(
|
|||
});
|
||||
}
|
||||
|
||||
if error.is_some() {
|
||||
EndpointStatus::warn(url, label, error)
|
||||
} else {
|
||||
EndpointStatus::ok(url, label)
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
if let Some(true) = endpoint.should_err {
|
||||
EndpointStatus::ok(url, label)
|
||||
} else {
|
||||
EndpointStatus::error(url, label, Some(format!("{}", e)))
|
||||
EndpointStatus {
|
||||
status: if error.is_some() { 1 } else { 0 },
|
||||
location: url,
|
||||
endpoint: label,
|
||||
error,
|
||||
}
|
||||
}
|
||||
Err(e) => EndpointStatus {
|
||||
status: 2,
|
||||
location: url,
|
||||
endpoint: label,
|
||||
error: Some(format!("{}", e)),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>endstat</title>
|
||||
<title>Endstat</title>
|
||||
<link href="https://fonts.googleapis.com/css?family=Montserrat:200|Source+Code+Pro:400" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
|
|
Loading…
Reference in a new issue