Compare commits

...

4 Commits

Author SHA1 Message Date
Edward Shen 3224c02d6f
liniting fixes 2019-11-09 17:25:42 -05:00
Edward Shen 2a56b0f4ad
remove extern crate statements 2019-11-09 17:13:11 -05:00
Edward Shen fa49084778
minor style changes 2019-11-09 17:12:53 -05:00
Edward Shen 2793469627
update cargo deps 2019-11-09 17:12:22 -05:00
6 changed files with 1252 additions and 1026 deletions

2246
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -8,17 +8,18 @@ edition = "2018"
reqwest = "0.9"
serde = { version = "1.0", features = ["derive"] }
ron = "0.5"
actix-web = { version = "1.0.0-beta.3", default-features = false, features = ["brotli", "flate2-zlib"] }
actix-web = { version = "1.0", default-features = false, features = ["brotli", "flate2-zlib"] }
actix = "0.8"
tokio = "0.1"
tera = "0.11"
env_logger = "0.6"
chrono = { version = "0.4", features = ["serde"] }
ring = "^0"
log="0.4"
rss = { version = "1.7.0", optional = true }
[features]
default = ["json"]
default = ["json", "webhooks"]
json = []
rss_feed = ["rss"]

View File

@ -1,16 +1,9 @@
#![forbid(unsafe_code)]
extern crate actix;
extern crate actix_web;
extern crate chrono;
extern crate env_logger;
extern crate reqwest;
extern crate ron;
extern crate serde;
extern crate tokio;
#[macro_use]
extern crate log;
#[macro_use]
extern crate tera;
extern crate ring;
#[cfg(feature = "rss_feed")]
extern crate rss;
@ -42,7 +35,7 @@ fn main() {
let conf_file_loc =
var("ENDSTAT_CONF").unwrap_or_else(|_| String::from("./config/endstat_conf.ron"));
let config = from_str::<Config>(
&read_to_string(&conf_file_loc).expect(&format!("finding {}", conf_file_loc)),
&read_to_string(&conf_file_loc).unwrap_or_else(|_| panic!("finding {}", conf_file_loc)),
)
.unwrap();
let bind_addr = &config.bind_address;

View File

@ -50,7 +50,9 @@ impl QueryResults {
($(($hook:ident, $cond:expr)),*) => {
$(if let Some(url) = &webhooks.$hook {
if new_endpoint.status == $cond {
client.post(url).json(new_endpoint).send();
if let Err(e) = client.post(url).json(new_endpoint).send() {
warn!("{}", e)
}
}
})*
};

View File

@ -74,8 +74,8 @@ fn get_result(
if let Some(expected_hash) = &endpoint.body_hash {
let expected = from_hex(expected_hash).unwrap();
let actual = digest(&SHA256, String::from(res_body).as_bytes());
if &expected != &actual.as_ref() {
let actual = digest(&SHA256, res_body.as_bytes());
if expected != actual.as_ref() {
errors.push(String::from("Body hash mismatch."));
}
} else if !body.is_empty() && res_body != body {
@ -112,7 +112,7 @@ fn get_result(
}
}
fn get_url(base: &Option<String>, path: &String, port: Option<u16>) -> Result<String, UrlError> {
fn get_url(base: &Option<String>, path: &str, port: Option<u16>) -> Result<String, UrlError> {
let mut url = if let Some(base) = base {
Url::parse(base)?.join(path)?
} else {

View File

@ -31,7 +31,7 @@
align-items: stretch;
background-color: #424242;
margin: 1rem 0;
border-radius: 1rem;
border-radius: .5rem;
}
p { margin: 0; }
@ -46,7 +46,7 @@
.indicator {
width: 1rem;
min-height: 100%;
border-radius: 1rem 0 0 1rem;
border-radius: .5rem 0 0 .5rem;
}
.ok { background-color: #4ed34e; }
.warn { background-color: #fcfc64; }