From 2ae5270d5e1b90b669663f41ff82fcd10e00b8ca Mon Sep 17 00:00:00 2001 From: Mylloon Date: Thu, 9 Feb 2023 12:42:39 +0100 Subject: [PATCH] Move the default configuration to the config file --- src/config.rs | 6 +++++- src/main.rs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index be1a23f..d986b54 100644 --- a/src/config.rs +++ b/src/config.rs @@ -20,7 +20,11 @@ pub fn get_config(file_path: &str) -> Config { Err(_) => // No config file { - Config::default() + Config { + scheme: Some("http".to_string()), + port: Some(8080), + ..Config::default() + } } } } diff --git a/src/main.rs b/src/main.rs index 3107d8c..7c89209 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,11 +30,11 @@ mod portfolio; async fn main() -> io::Result<()> { let config = config::get_config("./config/config.toml"); - let addr = ("127.0.0.1", config.port.unwrap_or(8080)); + let addr = ("127.0.0.1", config.port.unwrap()); println!( "Listening to {}://{}:{}", - config.clone().scheme.unwrap_or("http".to_string()), + config.clone().scheme.unwrap(), addr.0, addr.1 );