Browse Source

liniting fixes

master
Edward Shen 3 years ago
parent
commit
3224c02d6f
Signed by: edward
GPG Key ID: F350507060ED6C90
  1. 2
      src/main.rs
  2. 4
      src/results.rs
  3. 6
      src/updater.rs

2
src/main.rs

@ -35,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;

4
src/results.rs

@ -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)
}
}
})*
};

6
src/updater.rs

@ -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 {

Loading…
Cancel
Save