Added config support

This commit is contained in:
Connor Johnstone
2026-03-18 15:14:32 -04:00
parent ff41233a96
commit 32b4b533c0
11 changed files with 381 additions and 259 deletions

View File

@@ -196,3 +196,18 @@ pub async fn get_task(id: &str) -> Result<TaskInfo, ApiError> {
pub async fn get_config() -> Result<AppConfig, ApiError> {
get_json(&format!("{BASE}/config")).await
}
pub async fn save_config(config: &AppConfig) -> Result<AppConfig, ApiError> {
let body = serde_json::to_string(config).map_err(|e| ApiError(e.to_string()))?;
let resp = Request::put(&format!("{BASE}/config"))
.header("Content-Type", "application/json")
.body(&body)
.map_err(|e| ApiError(e.to_string()))?
.send()
.await
.map_err(|e| ApiError(e.to_string()))?;
if !resp.ok() {
return Err(ApiError(format!("HTTP {}", resp.status())));
}
resp.json().await.map_err(|e| ApiError(e.to_string()))
}