huskies: merge 768

This commit is contained in:
dave
2026-04-28 10:06:18 +00:00
parent fb5a21cfbb
commit 0c2789b2c1
11 changed files with 13 additions and 209 deletions
-23
View File
@@ -806,29 +806,6 @@ pub async fn gateway_event_push_handler(
.into_response()
}
// ── Health handler ──────────────────────────────────────────────────────────
/// HTTP GET `/health` handler for the gateway.
#[handler]
pub async fn gateway_health_handler(state: Data<&Arc<GatewayState>>) -> Response {
let (all_healthy, statuses) = gateway::health_check_all(&state).await;
let body = json!({
"status": if all_healthy { "ok" } else { "degraded" },
"projects": statuses,
});
let status = if all_healthy {
StatusCode::OK
} else {
StatusCode::SERVICE_UNAVAILABLE
};
Response::builder()
.status(status)
.header("Content-Type", "application/json")
.body(Body::from(serde_json::to_vec(&body).unwrap_or_default()))
}
// ── Gateway Web UI ──────────────────────────────────────────────────────────
/// `GET /api/gateway` — returns the list of registered projects and the active project.
-66
View File
@@ -1,66 +0,0 @@
//! Health check endpoint — thin HTTP adapter over `service::health`.
//!
//! Domain logic (the `HealthStatus` type and check function) lives in
//! `service::health`; this module is a thin adapter: call service → shape
//! response.
pub use crate::service::health::HealthStatus;
use poem::handler;
use poem_openapi::{OpenApi, Tags, payload::Json};
/// Health check endpoint.
///
/// Returns a static "ok" response to indicate the server is running.
#[handler]
pub fn health() -> &'static str {
"ok"
}
#[derive(Tags)]
enum HealthTags {
Health,
}
pub struct HealthApi;
#[OpenApi(tag = "HealthTags::Health")]
impl HealthApi {
/// Health check endpoint.
///
/// Returns a JSON status object to confirm the server is running.
#[oai(path = "/health", method = "get")]
async fn health(&self) -> Json<HealthStatus> {
Json(crate::service::health::check())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[tokio::test]
async fn handler_health_returns_ok() {
let app = poem::Route::new().at("/health", poem::get(health));
let cli = poem::test::TestClient::new(app);
let resp = cli.get("/health").send().await;
resp.assert_status_is_ok();
resp.assert_text("ok").await;
}
#[test]
fn health_status_serializes_to_json() {
let status = HealthStatus {
status: "ok".to_string(),
};
let json = serde_json::to_value(&status).unwrap();
assert_eq!(json["status"], "ok");
}
#[tokio::test]
async fn api_health_returns_ok_status() {
let api = HealthApi;
let response = api.health().await;
assert_eq!(response.0.status, "ok");
}
}
-6
View File
@@ -8,7 +8,6 @@ pub mod bot_config;
pub mod chat;
pub mod context;
pub mod events;
pub mod health;
pub mod identity;
pub mod io;
pub mod mcp;
@@ -30,7 +29,6 @@ use bot_command::BotCommandApi;
use bot_config::BotConfigApi;
use chat::ChatApi;
use context::AppContext;
use health::HealthApi;
use io::IoApi;
use model::ModelApi;
use poem::EndpointExt;
@@ -92,7 +90,6 @@ pub fn build_routes(
"/mcp",
post(mcp::mcp_post_handler).get(mcp::mcp_get_handler),
)
.at("/health", get(health::health))
.at("/identity", get(identity::identity_handler))
.at(
"/oauth/authorize",
@@ -204,7 +201,6 @@ type ApiTuple = (
ChatApi,
AgentsApi,
SettingsApi,
HealthApi,
BotCommandApi,
wizard::WizardApi,
BotConfigApi,
@@ -222,7 +218,6 @@ pub fn build_openapi_service(ctx: Arc<AppContext>) -> (ApiService, ApiService) {
ChatApi { ctx: ctx.clone() },
AgentsApi { ctx: ctx.clone() },
SettingsApi { ctx: ctx.clone() },
HealthApi,
BotCommandApi { ctx: ctx.clone() },
wizard::WizardApi { ctx: ctx.clone() },
BotConfigApi { ctx: ctx.clone() },
@@ -239,7 +234,6 @@ pub fn build_openapi_service(ctx: Arc<AppContext>) -> (ApiService, ApiService) {
ChatApi { ctx: ctx.clone() },
AgentsApi { ctx: ctx.clone() },
SettingsApi { ctx: ctx.clone() },
HealthApi,
BotCommandApi { ctx: ctx.clone() },
wizard::WizardApi { ctx: ctx.clone() },
BotConfigApi { ctx },