use crate::app_config::AppConfig; use crate::constants::StaticConstraints; use actix_web::HttpResponse; pub async fn secure_home() -> HttpResponse { HttpResponse::Ok() .content_type("text/plain") .body("SolarEnergy secure central backend") } #[derive(serde::Serialize)] struct ServerConfig { auth_disabled: bool, constraints: StaticConstraints, unsecure_origin: String, backend_version: &'static str, dashboard_custom_current_consumption_title: Option<&'static str>, dashboard_custom_relays_consumption_title: Option<&'static str>, dashboard_custom_cached_consumption_title: Option<&'static str>, } impl Default for ServerConfig { fn default() -> Self { Self { auth_disabled: AppConfig::get().unsecure_disable_login, constraints: Default::default(), unsecure_origin: AppConfig::get().unsecure_origin(), backend_version: env!("CARGO_PKG_VERSION"), dashboard_custom_current_consumption_title: AppConfig::get() .dashboard_custom_current_consumption_title .as_deref(), dashboard_custom_relays_consumption_title: AppConfig::get() .dashboard_custom_relays_consumption_title .as_deref(), dashboard_custom_cached_consumption_title: AppConfig::get() .dashboard_custom_cached_consumption_title .as_deref(), } } } pub async fn config() -> HttpResponse { HttpResponse::Ok().json(ServerConfig::default()) }