use axum::{ Json, extract::{Path, State}, }; use serde_json::Value; use unshell::{ ModuleError, config::{Tree, TreeMessage}, debug, }; use crate::Server; impl Server { pub async fn get_tree2_root( State(server): State, // Extension(extension): Extension, ) -> Json { Self::get_tree2(State(server), Path("".into())).await } pub async fn get_tree2( State(mut server): State, Path(path): Path, // Extension(_): Extension, ) -> Json { debug!("GET /api/interface/{}", path); let result = server .get(&path, TreeMessage::RequestStructAndValue) .map_err(|e| ModuleError::CryptError(e.to_string())); Json(serde_json::to_value(result).unwrap()) } pub async fn post_tree2( State(mut server): State, Path(path): Path, // Extension(_): Extension, Json(tree_message): Json, ) -> Json { debug!("POST /api/interface/"); // Json(Value::Null) let result = server .get(&path, tree_message) .map_err(|e| ModuleError::CryptError(e.to_string())); Json(serde_json::to_value(result).unwrap()) } }