use crate::app::AppState;
use crate::context::RequestContext;
use axum::extract::{Extension, State};
use axum::Json;
use serde::Serialize;

#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct HealthResponse {
    pub ok: bool,
    pub service: String,
    pub version: String,
    pub request_id: String,
    pub trace_id: String,
    pub runtime: &'static str,
}

pub async fn health(
    State(state): State<AppState>,
    Extension(context): Extension<RequestContext>,
) -> Json<HealthResponse> {
    Json(HealthResponse {
        ok: true,
        service: state.config().service_name.clone(),
        version: state.config().service_version.clone(),
        request_id: context.trace.request_id,
        trace_id: context.trace.trace_id,
        runtime: "axum",
    })
}
