list warrens + explore nested folders

This commit is contained in:
2025-07-12 06:39:43 +02:00
parent f9f55895ed
commit 4d0765c53b
38 changed files with 1877 additions and 93 deletions

View 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))
}

View File

@@ -0,0 +1,9 @@
use axum::{Json, extract::State};
use crate::{Result, api::AppState, warrens::Warren};
pub(super) async fn route(State(state): State<AppState>) -> Result<Json<Vec<Warren>>> {
let warrens = Warren::list(state.pool()).await?;
Ok(Json(warrens))
}

View File

@@ -0,0 +1,13 @@
mod get_warren_path;
mod list_warrens;
use axum::routing::get;
use crate::server::Router;
pub(super) fn router() -> Router {
Router::new()
.route("/", get(list_warrens::route))
.route("/{warren_id}", get(get_warren_path::route))
.route("/{warren_id}/{*rest}", get(get_warren_path::route))
}