Files
Shadowbroker/desktop-shell/tauri-skeleton/src-tauri/src/http_client.rs
T
anoracleofra-code 668ce16dc7 v0.9.6: InfoNet hashchain, Wormhole gate encryption, mesh reputation, 16 community contributors
Gate messages now propagate via the Infonet hashchain as encrypted blobs — every node syncs them
through normal chain sync while only Gate members with MLS keys can decrypt. Added mesh reputation
system, peer push workers, voluntary Wormhole opt-in for node participation, fork recovery,
killwormhole scripts, obfuscated terminology, and hardened the self-updater to protect encryption
keys and chain state during updates.

New features: Shodan search, train tracking, Sentinel Hub imagery, 8 new intelligence layers,
CCTV expansion to 11,000+ cameras across 6 countries, Mesh Terminal CLI, prediction markets,
desktop-shell scaffold, and comprehensive mesh test suite (215 frontend + backend tests passing).

Community contributors: @wa1id, @AlborzNazari, @adust09, @Xpirix, @imqdcr, @csysp, @suranyami,
@chr0n1x, @johan-martensson, @singularfailure, @smithbh, @OrfeoTerkuci, @deuza, @tm-const,
@Elhard1, @ttulttul
2026-03-26 05:58:04 -06:00

41 lines
1.3 KiB
Rust

use reqwest::Method;
use serde_json::Value;
pub async fn call_backend_json(
base_url: &str,
admin_key: Option<&str>,
path: &str,
method: Method,
payload: Option<Value>,
) -> Result<Value, String> {
let client = reqwest::Client::new();
let mut request = client.request(method, format!("{base_url}{path}"));
if let Some(key) = admin_key {
if !key.trim().is_empty() {
request = request.header("X-Admin-Key", key);
}
}
if let Some(value) = payload {
request = request.json(&value);
}
let response = request
.send()
.await
.map_err(|e| format!("backend_request_failed:{e}"))?;
let status = response.status();
let text = response
.text()
.await
.map_err(|e| format!("backend_response_failed:{e}"))?;
let value: Value = serde_json::from_str(&text).unwrap_or_else(|_| serde_json::json!({}));
if !status.is_success() || value.get("ok") == Some(&Value::Bool(false)) {
let detail = value
.get("detail")
.and_then(|v| v.as_str())
.or_else(|| value.get("message").and_then(|v| v.as_str()))
.unwrap_or("native_control_request_failed");
return Err(detail.to_string());
}
Ok(value)
}