Skip to content
Clone

refactor(repo): refresh compare handler

zhenyi committed
parent f48b108 commit 440bd07 Browse files

1 file changed

+5 −4

Modified lib/repo/handler/compare/compare.rs View lib/repo/handler/compare/compare.rs
@@ -1,5 +1,6 @@
1use axum::Json;
21use axum::extract::{Path, State};
2use export::data::AppResponseData;
3
34use jwt::extractor::AuthUser;
45use uuid::Uuid;
56
@@ -11,17 +12,17 @@
1112 get,
1213 path = "/repo/{channel_id}/{repo_id}/compare/{base}...{head}",
1314 tag = "repo",
14 responses((status = 200, description = "Compare two refs", body = CompareView)),
15 responses((status = 200, description = "Compare two refs", body = AppResponseData<CompareView>)),
1516 security(("bearer_auth" = []))
1617)]
1718pub(crate) async fn handler(
1819 State(svc): State<RepoService>,
1920 AuthUser { claims }: AuthUser,
2021 Path((_, repo_id, base_dot_head)): Path<(Uuid, Uuid, String)>,
21) -> RepoResult<Json<CompareView>> {
22) -> RepoResult<AppResponseData<CompareView>> {
2223 let (base, head) = base_dot_head
2324 .split_once("...")
2425 .ok_or_else(|| crate::error::RepoError::BadRequest("expected '<base>...<head>'".into()))?;
2526 let view = svc.compare(claims.sub, repo_id, base, head).await?;
26 Ok(Json(view))
27 Ok(AppResponseData::ok(view))
2728}