From 3a96e98f4579f7aadca2e2b00421ab31cf4772cb Mon Sep 17 00:00:00 2001 From: Lennart <18233294+lennart-k@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:08:24 +0100 Subject: [PATCH] config: default http options --- src/config.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/config.rs b/src/config.rs index 04989b1..1056c06 100644 --- a/src/config.rs +++ b/src/config.rs @@ -2,12 +2,30 @@ use rustical_frontend::FrontendConfig; use rustical_store::auth::StaticUserStoreConfig; use serde::{Deserialize, Serialize}; +fn http_default_host() -> String { + "0.0.0.0".to_owned() +} +fn http_default_port() -> u16 { + 4000 +} + #[derive(Debug, Deserialize, Serialize)] pub struct HttpConfig { + #[serde(default = "http_default_host")] pub host: String, + #[serde(default = "http_default_port")] pub port: u16, } +impl Default for HttpConfig { + fn default() -> Self { + Self { + host: http_default_host(), + port: http_default_port(), + } + } +} + #[derive(Debug, Deserialize, Serialize)] pub struct SqliteDataStoreConfig { pub db_url: String, @@ -34,6 +52,7 @@ pub struct TracingConfig { pub struct Config { pub data_store: DataStoreConfig, pub auth: AuthConfig, + #[serde(default)] pub http: HttpConfig, pub frontend: FrontendConfig, #[serde(default)]