wsprism_gateway/config/
mod.rs1pub mod schema;
7
8use std::fs;
9
10use wsprism_core::error::{Result, WsPrismError};
11
12pub use schema::{GatewayConfig, TenantConfig, TenantLimits, TenantPolicy};
13
14pub fn load_from_file(path: &str) -> Result<GatewayConfig> {
15 let s = fs::read_to_string(path)
16 .map_err(|e| WsPrismError::Internal(format!("read config failed: {e}")))?;
17 load_from_str(&s)
18}
19
20pub fn load_from_str(s: &str) -> Result<GatewayConfig> {
21 let cfg: GatewayConfig = serde_yaml::from_str(s)
22 .map_err(|e| WsPrismError::BadRequest(format!("invalid yaml: {e}")))?;
23 cfg.validate()?;
24 Ok(cfg)
25}