main: Make http host configurable

This commit is contained in:
Lennart
2024-01-21 14:38:24 +01:00
parent eb9e317e6f
commit 52ada57e35
2 changed files with 8 additions and 1 deletions

View File

@@ -1,6 +1,12 @@
use rustical_auth::{AuthProvider, HtpasswdAuthConfig}; use rustical_auth::{AuthProvider, HtpasswdAuthConfig};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
pub struct HttpConfig {
pub host: String,
pub port: u16,
}
#[derive(Debug, Deserialize, Serialize)] #[derive(Debug, Deserialize, Serialize)]
pub struct TomlCalendarStoreConfig { pub struct TomlCalendarStoreConfig {
pub db_path: String, pub db_path: String,
@@ -40,4 +46,5 @@ impl From<AuthConfig> for AuthProvider {
pub struct Config { pub struct Config {
pub calendar_store: CalendarStoreConfig, pub calendar_store: CalendarStoreConfig,
pub auth: AuthConfig, pub auth: AuthConfig,
pub http: HttpConfig,
} }

View File

@@ -69,7 +69,7 @@ async fn main() -> Result<()> {
web::scope("/api").configure(|cfg| configure_api(cfg, cal_store.clone().into())), 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() .run()
.await?; .await?;
Ok(()) Ok(())