huskies: merge 775
This commit is contained in:
@@ -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};
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user