provisioning-platform/crates/ai-service/src/api_catalog.rs

13 lines
498 B
Rust
Raw Normal View History

use axum::{extract::State, response::IntoResponse, Json};
use ontoref_ontology::api::ApiRouteEntry;
use serde_json::json;
use std::sync::Arc;
use crate::service::AiService;
pub async fn api_catalog(State(_state): State<Arc<AiService>>) -> impl IntoResponse {
let mut routes: Vec<&'static ApiRouteEntry> = inventory::iter::<ApiRouteEntry>().collect();
routes.sort_by(|a, b| a.path.cmp(b.path).then(a.method.cmp(b.method)));
Json(json!({ "service": "ai-service", "routes": routes }))
}