From 691c7663123e481cfe193abe4e2e69cf1fe5305d Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 8 Feb 2023 20:58:24 +0100 Subject: [PATCH] add port on config --- src/config.rs | 2 ++ src/main.rs | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 53734ea..75a802b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -3,6 +3,7 @@ use serde::Deserialize; #[derive(Deserialize)] pub struct Config { pub scheme: String, + pub port: u16, } pub fn get_config(file_path: &str) -> Config { @@ -18,6 +19,7 @@ pub fn get_config(file_path: &str) -> Config { { Config { scheme: "http".to_string(), + port: 8080, } } } diff --git a/src/main.rs b/src/main.rs index 72865c9..df628e0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,8 +9,9 @@ mod index; async fn main() -> std::io::Result<()> { let config = config::get_config("config/config.toml"); - let addr = ("127.0.0.1", 8080); + let addr = ("127.0.0.1", config.port); println!("Listening to {}://{}:{}", config.scheme, addr.0, addr.1); + HttpServer::new(|| App::new().service(index::page)) .bind(addr)? .run()