Skip to content
Clone
d5939db
34 lines 975 B Rust
use axum::extract::{Path, Query, State};
use export::data::AppResponseData;
use jwt::extractor::AuthUser;
use uuid::Uuid;
use crate::error::RepoResult;
use crate::features::RepoService;
use crate::features::git_ref::TreeView;
#[derive(serde::Deserialize, utoipa::IntoParams)]
pub struct TreeQuery {
pub recursive: Option<bool>,
}
#[utoipa::path(
get,
path = "/repo/{channel_id}/{repo_id}/git/trees/{sha}",
tag = "repo",
params(TreeQuery),
responses((status = 200, description = "Get a tree", body = AppResponseData<TreeView>)),
security(("bearer_auth" = []))
)]
pub(crate) async fn handler(
State(svc): State<RepoService>,
AuthUser { claims }: AuthUser,
Path((_, repo_id, sha)): Path<(Uuid, Uuid, String)>,
Query(q): Query<TreeQuery>,
) -> RepoResult<AppResponseData<TreeView>> {
let view = svc
.get_tree(claims.sub, repo_id, &sha, q.recursive.unwrap_or(false))
.await?;
Ok(AppResponseData::ok(view))
}