all the config is optional
This commit is contained in:
parent
00cd6405ea
commit
d57231cfc4
2 changed files with 12 additions and 6 deletions
|
@ -2,8 +2,8 @@ use serde::Deserialize;
|
|||
|
||||
#[derive(Deserialize, Clone)]
|
||||
pub struct Config {
|
||||
pub scheme: String,
|
||||
pub port: u16,
|
||||
pub scheme: Option<String>,
|
||||
pub port: Option<u16>,
|
||||
pub mail: Option<String>,
|
||||
pub lang: Option<String>,
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ pub fn get_config(file_path: &str) -> Config {
|
|||
// No config file
|
||||
{
|
||||
Config {
|
||||
scheme: "http".to_string(),
|
||||
port: 8080,
|
||||
scheme: None,
|
||||
port: None,
|
||||
mail: None,
|
||||
lang: None,
|
||||
}
|
||||
|
|
10
src/main.rs
10
src/main.rs
|
@ -31,8 +31,14 @@ mod portfolio;
|
|||
async fn main() -> io::Result<()> {
|
||||
let config = config::get_config("/config/config.toml");
|
||||
|
||||
let addr = ("127.0.0.1", config.port);
|
||||
println!("Listening to {}://{}:{}", config.scheme, addr.0, addr.1);
|
||||
let addr = ("127.0.0.1", config.port.unwrap_or(8080));
|
||||
|
||||
println!(
|
||||
"Listening to {}://{}:{}",
|
||||
config.clone().scheme.unwrap_or("http".to_string()),
|
||||
addr.0,
|
||||
addr.1
|
||||
);
|
||||
|
||||
let static_folder = "static";
|
||||
let dist_folder = format!("dist/{static_folder}");
|
||||
|
|
Loading…
Reference in a new issue