use serde::{Deserialize, Serialize}; #[derive(Deserialize, Serialize, Debug, Clone, Default)] pub struct Config { pub refresh_time: u64, pub bind_address: String, pub websites: Vec, } #[derive(Deserialize, Serialize, Debug, Clone)] pub struct WebsiteConfig { pub label: String, pub base: Option, pub endpoints: Vec, } #[derive(Deserialize, Serialize, Debug, Clone)] pub struct EndpointConfig { pub label: Option, pub endpoint: Option, pub port: Option, pub code: Option, pub body: Option, pub body_hash: Option, pub follow_redirects: Option, pub max_rtt: Option, pub should_err: Option, pub webhooks: Option, } #[derive(Deserialize, Serialize, Debug, Clone)] pub struct Webhooks { pub on_change: Option, pub on_ok: Option, pub on_warn: Option, pub on_error: Option, pub on_not_ok: Option, } pub fn get_endpoint_info(endpoint: EndpointConfig) -> (String, String, Option, u16, String) { let path = endpoint.endpoint.unwrap_or_default(); let label = endpoint.label.unwrap_or_else(|| path.clone()); let code = endpoint.code.unwrap_or_else(|| 200); let body = endpoint.body.unwrap_or_default(); (label, path, endpoint.port, code, body) }