Move the default configuration to the config file

This commit is contained in:
Mylloon 2023-02-09 12:42:39 +01:00
parent 81a50a237d
commit 2ae5270d5e
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
2 changed files with 7 additions and 3 deletions

View file

@ -20,7 +20,11 @@ pub fn get_config(file_path: &str) -> Config {
Err(_) => Err(_) =>
// No config file // No config file
{ {
Config::default() Config {
scheme: Some("http".to_string()),
port: Some(8080),
..Config::default()
}
} }
} }
} }

View file

@ -30,11 +30,11 @@ mod portfolio;
async fn main() -> io::Result<()> { async fn main() -> io::Result<()> {
let config = config::get_config("./config/config.toml"); 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!( println!(
"Listening to {}://{}:{}", "Listening to {}://{}:{}",
config.clone().scheme.unwrap_or("http".to_string()), config.clone().scheme.unwrap(),
addr.0, addr.0,
addr.1 addr.1
); );