hive-agent: replace json! with typed structs in web_ui handlers
This commit is contained in:
parent
127846ef1b
commit
786e4610f0
3 changed files with 34 additions and 15 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use axum::extract::State;
|
||||
use axum::response::{IntoResponse, Response};
|
||||
use serde::Deserialize;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::AppState;
|
||||
|
||||
|
|
@ -40,6 +40,11 @@ async fn fetch_reminder_stats(window_secs: u64) -> Option<hive_sh4re::approvals:
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct TodosBody {
|
||||
todos: Vec<hive_sh4re::inbox::LooseEnd>,
|
||||
}
|
||||
|
||||
/// `GET /api/todos` — snapshot of this agent's local todos (loose-ends v2).
|
||||
///
|
||||
/// Connects to the in-agent harness socket (`HIVE_AGENT_SOCKET`) and calls
|
||||
|
|
@ -54,5 +59,5 @@ pub(super) async fn api_todos() -> Response {
|
|||
Some(hive_agent_sock::Response::LooseEnds { loose_ends }) => loose_ends,
|
||||
_ => Vec::new(),
|
||||
};
|
||||
axum::Json(serde_json::json!({ "todos": todos })).into_response()
|
||||
axum::Json(TodosBody { todos }).into_response()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue