diff --git a/src/config.rs b/src/config.rs index cd9610a..cb85075 100644 --- a/src/config.rs +++ b/src/config.rs @@ -44,7 +44,7 @@ impl Auth { let mut hasher = Sha256::new(); hasher.update(token); let result = hasher.finalize(); - return format!("{:x}", result) == self.hash; + format!("{:x}", result) == self.hash } _ => false, } @@ -81,7 +81,7 @@ fn default_opentsdb_url() -> String { pub fn load_config_file(filename: &str) -> Config { let yaml_content = fs::read_to_string(filename) - .expect(format!("Unable to read config file {}", filename).as_str()); + .unwrap_or_else(|_| panic!("Unable to read config file {}", filename)); let config: Config = serde_yaml::from_str(&yaml_content).expect("Unable to parse YAML"); config } diff --git a/src/main.rs b/src/main.rs index 5ce6c45..ff50c03 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use actix_web::http::StatusCode; use actix_web::middleware::Logger; -use actix_web::{error, web, App, HttpResponse, HttpServer, Responder}; -use log::{debug, error, info, log_enabled, Level}; +use actix_web::{web, App, HttpResponse, HttpServer, Responder}; +use log::{debug, error, info}; use reqwest::Client; use serde::{Deserialize, Serialize}; use std::collections::HashMap; @@ -64,7 +64,7 @@ async fn put_post( client.metrics.join(", ") ); error!("{}", emsg); - return HttpResponse::Forbidden().body(format!("{}", emsg)); + return HttpResponse::Forbidden().body(emsg.to_string()); } let post_url = format!("{}put", shared.cfg.config.opentsdb.url); @@ -113,10 +113,7 @@ async fn main() -> std::io::Result<()> { let web_client = Client::new(); - let shared = ClientData { - web_client: web_client, - cfg: cfg, - }; + let shared = ClientData { web_client, cfg }; let client_data = web::Data::new(shared); HttpServer::new(move || {