From 52ada57e354439eea031d9e12df2141e0b1ecb53 Mon Sep 17 00:00:00 2001 From: Lennart <18233294+lennart-k@users.noreply.github.com> Date: Sun, 21 Jan 2024 14:38:24 +0100 Subject: [PATCH] main: Make http host configurable --- src/config.rs | 7 +++++++ src/main.rs | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index f41b201..15416fb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -1,6 +1,12 @@ use rustical_auth::{AuthProvider, HtpasswdAuthConfig}; use serde::{Deserialize, Serialize}; +#[derive(Debug, Deserialize, Serialize)] +pub struct HttpConfig { + pub host: String, + pub port: u16, +} + #[derive(Debug, Deserialize, Serialize)] pub struct TomlCalendarStoreConfig { pub db_path: String, @@ -40,4 +46,5 @@ impl From for AuthProvider { pub struct Config { pub calendar_store: CalendarStoreConfig, pub auth: AuthConfig, + pub http: HttpConfig, } diff --git a/src/main.rs b/src/main.rs index 9884ba7..861221b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -69,7 +69,7 @@ async fn main() -> Result<()> { web::scope("/api").configure(|cfg| configure_api(cfg, cal_store.clone().into())), ) }) - .bind(("0.0.0.0", 4000))? + .bind((config.http.host, config.http.port))? .run() .await?; Ok(())