2025-12-17 16:40:34 -07:00
|
|
|
use axum::{
|
2025-12-23 23:09:05 -07:00
|
|
|
Json,
|
2025-12-17 16:40:34 -07:00
|
|
|
extract::{Path, State},
|
|
|
|
|
};
|
2025-12-21 00:35:28 -07:00
|
|
|
|
2025-12-17 16:40:34 -07:00
|
|
|
use serde_json::Value;
|
2026-01-26 09:13:46 -07:00
|
|
|
use unshell::{
|
2025-12-21 00:35:28 -07:00
|
|
|
ModuleError,
|
|
|
|
|
config::{Tree, TreeMessage},
|
|
|
|
|
debug,
|
|
|
|
|
};
|
2025-12-17 16:40:34 -07:00
|
|
|
|
2025-12-23 23:09:05 -07:00
|
|
|
use crate::Server;
|
2025-12-17 16:40:34 -07:00
|
|
|
|
2025-12-21 00:35:28 -07:00
|
|
|
impl Server {
|
|
|
|
|
pub async fn get_tree2_root(
|
|
|
|
|
State(server): State<Server>,
|
2025-12-21 17:58:04 -07:00
|
|
|
// Extension(extension): Extension<CurrentUser>,
|
2025-12-21 00:35:28 -07:00
|
|
|
) -> Json<Value> {
|
2025-12-21 17:58:04 -07:00
|
|
|
Self::get_tree2(State(server), Path("".into())).await
|
2025-12-17 16:40:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub async fn get_tree2(
|
2025-12-21 12:04:53 -07:00
|
|
|
State(mut server): State<Server>,
|
2025-12-17 16:40:34 -07:00
|
|
|
Path(path): Path<String>,
|
2025-12-21 17:58:04 -07:00
|
|
|
// Extension(_): Extension<CurrentUser>,
|
2025-12-17 16:40:34 -07:00
|
|
|
) -> Json<Value> {
|
|
|
|
|
debug!("GET /api/interface/{}", path);
|
|
|
|
|
|
2025-12-21 00:35:28 -07:00
|
|
|
let result = server
|
|
|
|
|
.get(&path, TreeMessage::RequestStructAndValue)
|
|
|
|
|
.map_err(|e| ModuleError::CryptError(e.to_string()));
|
2025-12-17 16:40:34 -07:00
|
|
|
|
|
|
|
|
Json(serde_json::to_value(result).unwrap())
|
|
|
|
|
}
|
2025-12-21 12:04:53 -07:00
|
|
|
|
|
|
|
|
pub async fn post_tree2(
|
|
|
|
|
State(mut server): State<Server>,
|
|
|
|
|
Path(path): Path<String>,
|
2025-12-21 17:58:04 -07:00
|
|
|
// Extension(_): Extension<CurrentUser>,
|
2025-12-21 12:04:53 -07:00
|
|
|
Json(tree_message): Json<TreeMessage>,
|
|
|
|
|
) -> Json<Value> {
|
2025-12-21 17:58:04 -07:00
|
|
|
debug!("POST /api/interface/");
|
|
|
|
|
|
|
|
|
|
// Json(Value::Null)
|
2025-12-21 12:04:53 -07:00
|
|
|
|
|
|
|
|
let result = server
|
|
|
|
|
.get(&path, tree_message)
|
|
|
|
|
.map_err(|e| ModuleError::CryptError(e.to_string()));
|
|
|
|
|
|
|
|
|
|
Json(serde_json::to_value(result).unwrap())
|
|
|
|
|
}
|
2025-12-17 16:40:34 -07:00
|
|
|
}
|