dkp 0.1.0

dkp — Domain Knowledge Pack management CLI
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use axum::{
    extract::State,
    http::StatusCode,
    response::{IntoResponse, Json, Response},
};
use serde_json::Value;
use std::sync::Arc;

use crate::cmd::webui::server::AppState;

pub async fn get_graph(State(state): State<Arc<AppState>>) -> Response {
    match state.pack.load_graph() {
        Ok(Some(graph)) => Json(graph).into_response(),
        Ok(None) => Json(Value::Null).into_response(),
        Err(e) => (StatusCode::INTERNAL_SERVER_ERROR, e.to_string()).into_response(),
    }
}