huskies: merge 775

This commit is contained in:
dave
2026-04-28 12:25:59 +00:00
parent e9ed58502a
commit b7db6d6aae
10 changed files with 139 additions and 46 deletions
-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.