use export::http::{Bytes, Path, State}; use export::rest::AppResponseData; use jwt::Session; use crate::errors::{ApiError, GitApiError}; use crate::handler::{RepoPath, require_writer}; use crate::service::GitService; use crate::service::packs::IngestPackDto; #[utoipa::path( post, path = "/repos/{space_name}/{repo_name}/packs/ingest", tag = "packs", description = "接收 packfile 二进制内容并索引到仓库对象库。", params(RepoPath), request_body = String, responses( (status = 200, description = "ingest pack file", body = AppResponseData) ) )] pub async fn ingest( State(service): State, session: Session, Path(path): Path, body: Bytes, ) -> Result, ApiError> { require_writer( &service, &session, path.space_name.clone(), path.repo_name.clone(), ) .await?; let out = service .pack_ingest(path.space_name, path.repo_name, body.to_vec()) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(out)) }