Rename things to ush for brevity. Add Tree system.

This commit is contained in:
Michael Mikovsky
2026-02-09 10:27:15 -07:00
parent ebeaa29d5b
commit 2a18639d84
86 changed files with 368 additions and 419 deletions
+53
View File
@@ -0,0 +1,53 @@
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<Server>,
// Extension(extension): Extension<CurrentUser>,
) -> Json<Value> {
Self::get_tree2(State(server), Path("".into())).await
}
pub async fn get_tree2(
State(mut server): State<Server>,
Path(path): Path<String>,
// Extension(_): Extension<CurrentUser>,
) -> Json<Value> {
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<Server>,
Path(path): Path<String>,
// Extension(_): Extension<CurrentUser>,
Json(tree_message): Json<TreeMessage>,
) -> Json<Value> {
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())
}
}