use crate::serve::error::ServeError;
use crate::serve::load::load_submission;
use crate::serve::runner::{ConfigFormatWire, run_doctor_first};
use crate::serve::state::ServerState;
use axum::Json;
use axum::extract::State;
use serde::Deserialize;
use serde_json::Value;
#[derive(Debug, Deserialize)]
pub struct DoctorRequest {
pub config: String,
#[serde(default)]
pub config_format: ConfigFormatWire,
}
pub async fn doctor(
State(state): State<ServerState>,
Json(req): Json<DoctorRequest>,
) -> Result<Json<Value>, ServeError> {
let loaded = load_submission(
&req.config,
req.config_format.into(),
state.default_base().as_ref(),
)
.await?;
let report = run_doctor_first(&state, &loaded).await?;
Ok(Json(report))
}