use axum::{routing::get, Router}; use serde::Serialize; use truth::default_truth_store; #[allow(dead_code)] pub fn truth_router() -> Router { Router::new() .route("/context", get(context)) } #[derive(Serialize)] pub struct ContextResponse { pub task_classes: Vec, pub rules: Vec, } #[derive(Serialize)] pub struct RuleInfo { pub id: String, pub task_class: String, pub description: String, } pub async fn context() -> axum::Json { let store = default_truth_store(); let task_classes: Vec = vec![ "staffing.fill".to_string(), "staffing.rescue".to_string(), "staffing.sms_draft".to_string(), "staffing.any".to_string(), ]; let mut rules = Vec::new(); for tc in &task_classes { for rule in store.get_rules(tc) { rules.push(RuleInfo { id: rule.id.clone(), task_class: rule.task_class.clone(), description: rule.description.clone(), }); } } axum::Json(ContextResponse { task_classes, rules, }) }