use axum::extract::State;
use axum::http::StatusCode;
use axum::response::{IntoResponse, Response};
use crate::state::AppState;
pub async fn healthz() -> &'static str {
"ok"
}
pub async fn readyz(State(state): State<AppState>) -> Response {
match sqlx::query("SELECT 1").execute(&state.pool).await {
Ok(_) => (StatusCode::OK, "ready").into_response(),
Err(e) => {
tracing::warn!(error = %e, "readyz: database unreachable");
(StatusCode::SERVICE_UNAVAILABLE, "database unavailable").into_response()
}
}
}