huskies: merge 775

This commit is contained in:
dave
2026-04-28 12:19:49 +00:00
parent e9ed58502a
commit b7db6d6aae
10 changed files with 139 additions and 46 deletions
+1 -1
View File
@@ -19,6 +19,6 @@ pub use rest::{
gateway_add_project_handler, gateway_api_handler, gateway_assign_agent_handler,
gateway_bot_config_get_handler, gateway_bot_config_page_handler,
gateway_bot_config_save_handler, gateway_generate_token_handler, gateway_list_agents_handler,
gateway_mode_handler, gateway_remove_project_handler, gateway_switch_handler,
gateway_mode_handler, gateway_remove_project_handler,
};
pub use websocket::{gateway_crdt_sync_handler, gateway_event_push_handler};
-34
View File
@@ -100,40 +100,6 @@ pub async fn gateway_api_handler(state: Data<&Arc<GatewayState>>) -> Response {
.body(Body::from(serde_json::to_vec(&body).unwrap_or_default()))
}
/// Request body for `POST /api/gateway/switch`.
#[derive(Deserialize)]
struct SwitchRequest {
project: String,
}
/// `POST /api/gateway/switch` — switch the active project.
#[handler]
pub async fn gateway_switch_handler(
state: Data<&Arc<GatewayState>>,
body: Json<SwitchRequest>,
) -> Response {
match gateway::switch_project(&state, &body.project).await {
Ok(_) => {
let body_val = json!({ "ok": true });
Response::builder()
.status(StatusCode::OK)
.header("Content-Type", "application/json")
.body(Body::from(
serde_json::to_vec(&body_val).unwrap_or_default(),
))
}
Err(e) => {
let body_val = json!({ "ok": false, "error": e.to_string() });
Response::builder()
.status(StatusCode::BAD_REQUEST)
.header("Content-Type", "application/json")
.body(Body::from(
serde_json::to_vec(&body_val).unwrap_or_default(),
))
}
}
}
// ── Project management API ────────────────────────────────────────────────────
/// Request body for adding a new project.