From bd7dce7981ec9d7ae30ed25fd71de16498bc3963 Mon Sep 17 00:00:00 2001 From: MCorange99 Date: Sat, 23 Mar 2024 22:29:28 +0200 Subject: [PATCH] Implemented user specifieable host and port --- src/main.rs | 2 +- src/public/mod.rs | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 7dffd97..1fe181e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,7 +10,7 @@ async fn main() -> std::io::Result<()> { logger::init_logger(&cli); - if let Err(e) = public::start_actix().await { + if let Err(e) = public::start_actix(&cli).await { log::error!("Actix had an error: {e}"); } Ok(()) diff --git a/src/public/mod.rs b/src/public/mod.rs index e7620ea..c854b21 100644 --- a/src/public/mod.rs +++ b/src/public/mod.rs @@ -4,14 +4,18 @@ mod templates; use actix_web::{web, App, HttpServer}; -pub(crate) async fn start_actix() -> anyhow::Result<()> { - log::info!("Serving an http server at http://0.0.0.0:8080"); +use crate::cli::CliArgs; + +pub(crate) async fn start_actix(cli: &CliArgs) -> anyhow::Result<()> { + let bindip = format!("{}:{}", cli.host, cli.port); + + log::info!("Serving an http server at http://{bindip}"); HttpServer::new(|| { App::new() .route("/", web::get().to(routes::index)) }) - .bind("0.0.0.0:8080")? + .bind(bindip)? .run() .await?;