Files
SolarEnergy/central_backend/src/server/web_api/server_controller.rs
Pierre HUBERT d6e0eccb00
All checks were successful
continuous-integration/drone/push Build is passing
Make dashboard titles customizable
2024-11-19 19:02:09 +01:00

45 lines
1.5 KiB
Rust

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())
}