diff --git a/src/configuration.rs b/src/configuration.rs index df0fc2d..ffd4296 100644 --- a/src/configuration.rs +++ b/src/configuration.rs @@ -3,6 +3,8 @@ extern crate serde_json; use std::fs::File; use std::io::prelude::*; use weld; +use std::path::Path; + #[derive(Serialize, Deserialize)] #[derive(Debug,Clone)] @@ -12,7 +14,7 @@ pub struct Configuration { } impl Configuration { - pub fn new(path: &String) -> Configuration { + pub fn new (path: &str) -> Configuration { if path != "" { info!(weld::ROOT_LOGGER, "Configuration - Reading Path: {:?}", &path); let mut file = File::open(path).expect("Configuration - Error Can't read provided configuration. Terminating..."); @@ -41,7 +43,7 @@ impl Configuration { }; } } - pub fn load(&mut self, path: &String) { + pub fn load(&mut self, path: &str) { let configuration = Configuration::new(&path); self.server = configuration.server; self.database = configuration.database; diff --git a/src/main.rs b/src/main.rs index ca86c13..1e650b6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,7 +47,7 @@ pub mod weld { lazy_static! { pub static ref ROOT_LOGGER: slog::Logger = slog::Logger::root(Arc::new(slog_async::Async::new(slog_term::CompactFormat::new(slog_term::TermDecorator::new().build()).build().fuse()).build().fuse()), o!()); - pub static ref CONFIGURATION : Mutex = Mutex::new(Configuration::new(&"".to_string())); + pub static ref CONFIGURATION : Mutex = Mutex::new(Configuration::new("")); pub static ref DATABASE : Mutex = Mutex::new(Database::new(&configuration::Database{path:"".to_string()})); } } @@ -56,10 +56,10 @@ fn main() { info!(weld::ROOT_LOGGER, "Application started";"started_at" => format!("{}", time::now().rfc3339()), "version" => env!("CARGO_PKG_VERSION")); let mut configuration = weld::CONFIGURATION.lock().unwrap(); match args().nth(1) { - Some(path) => configuration.load(&path.to_string()), + Some(path) => configuration.load(path.as_str()), None => { info!(weld::ROOT_LOGGER,"Program arguments not found."); - configuration.load(&"weld.json".to_string()); + configuration.load("weld.json"); } } load_db(&configuration);