split backend into bin and lib
This commit is contained in:
27
backend/src/lib/api/warrens/get_warren_path.rs
Normal file
27
backend/src/lib/api/warrens/get_warren_path.rs
Normal file
@@ -0,0 +1,27 @@
|
||||
use axum::Json;
|
||||
use axum::extract::{Path, State};
|
||||
use serde::Deserialize;
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::Result;
|
||||
use crate::api::AppState;
|
||||
use crate::warrens::Warren;
|
||||
|
||||
use crate::fs::DirectoryEntry;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
pub(super) struct WarrenRequestPath {
|
||||
warren_id: Uuid,
|
||||
rest: Option<String>,
|
||||
}
|
||||
|
||||
pub(super) async fn route(
|
||||
State(state): State<AppState>,
|
||||
Path(WarrenRequestPath { warren_id, rest }): Path<WarrenRequestPath>,
|
||||
) -> Result<Json<Vec<DirectoryEntry>>> {
|
||||
let warren = Warren::get(state.pool(), &warren_id).await?;
|
||||
|
||||
let entries = warren.read_path(state.serve_dir(), rest).await?;
|
||||
|
||||
Ok(Json(entries))
|
||||
}
|
||||
Reference in New Issue
Block a user