This commit is contained in:
Kelorastus
2026-09-16 11:42:24 +02:00
parent b7f3061be3
commit 3fdfde7043
18 changed files with 1485 additions and 21 deletions
+6 -5
View File
@@ -11,10 +11,13 @@ pub struct Probe {
pub online: bool,
/// The site's CURRENT version.
pub version: Option<String>,
/// The DHP's Engine API, as this PC can reach it: where live mode forwards while
/// online. Absent when the DHP offers none, and this PC then serves its own data.
pub engine_url: Option<String>,
}
pub async fn probe(http: &reqwest::Client, site_url: &str) -> Probe {
let offline = Probe { online: false, version: None };
let offline = Probe { online: false, version: None, engine_url: None };
if site_url.is_empty() {
return offline;
}
@@ -25,10 +28,8 @@ pub async fn probe(http: &reqwest::Client, site_url: &str) -> Probe {
return offline;
}
let body: serde_json::Value = response.json().await.unwrap_or_default();
Probe {
online: true,
version: body.get("version").and_then(|v| v.as_str()).map(str::to_string),
}
let text = |key: &str| body.get(key).and_then(|v| v.as_str()).filter(|s| !s.is_empty()).map(str::to_string);
Probe { online: true, version: text("version"), engine_url: text("engine_api_url") }
}
pub enum TokenCheck {