M4
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user