Skip to content
Clone
fb04cec
47 lines 1.3 KB Rust
use axum::extract::{Path, Query, State};
use export::rest::AppResponseData;
use session::Session;
use crate::errors::{ApiError, GitApiError};
use crate::handler::resolve_reader;
use crate::service::GitService;
use crate::service::trees::PathLastUpdated;
#[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)]
pub struct TreeLastUpdatedQuery {
pub revision: String,
#[serde(default)]
pub path: Option<String>,
}
#[utoipa::path(
get,
path = "/repos/{space_name}/{repo_name}/tree/last-updated",
tag = "trees",
params(
crate::handler::RepoPath,
TreeLastUpdatedQuery,
),
responses(
(status = 200, description = "last updated tree entries", body = AppResponseData<Vec<PathLastUpdated>>)
)
)]
pub async fn tree_last_updated(
State(service): State<GitService>,
session: Session,
Path(path): Path<crate::handler::RepoPath>,
Query(q): Query<TreeLastUpdatedQuery>,
) -> Result<AppResponseData<Vec<PathLastUpdated>>, ApiError> {
let _ = resolve_reader(
&service,
&session,
path.space_name.clone(),
path.repo_name.clone(),
)
.await?;
let out = service
.tree_last_updated(path.space_name, path.repo_name, q.revision, q.path)
.await
.map_err(GitApiError::from)?;
Ok(AppResponseData::ok(out))
}