use ::session::Session; use export::http::{Path, State}; use export::rest::AppResponseData; use crate::errors::{ApiError, GitApiError}; use crate::handler; use crate::service::GitService; use crate::service::blobs::BlobContentDto; #[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)] pub struct BlobPath { pub space_name: String, pub repo_name: String, pub oid: String, } #[utoipa::path( get, path = "/repos/{space_name}/{repo_name}/blobs/{oid}/content", tag = "blobs", description = "读取 Blob 原始内容,超过配置上限时截断并标记。", params(BlobPath), responses( (status = 200, description = "blob content", body = AppResponseData) ) )] pub async fn blob_content( State(service): State, session: Session, Path(path): Path, ) -> Result, ApiError> { let (ctx, _) = handler::resolve_reader( &service, &session, path.space_name.clone(), path.repo_name.clone(), ) .await?; let out = service .blob_content(&ctx, path.oid) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(out)) }