refactor(repo): refresh branch_protection edit handler
zhenyi committed
Modified lib/repo/handler/branch_protection/edit.rs lib/repo/handler/branch_protection/edit.rs +8 −7 View lib/repo/handler/branch_protection/edit.rs
@@ -1,5 +1,6 @@
1use axum::Json;
21use axum::extract::{Path, State};
2use export::data::{AppRequest, AppRequestData, AppResponseData};
3
34use jwt::extractor::AuthUser;
45use uuid::Uuid;
56
@@ -11,18 +12,18 @@
1112 patch,
1213 path = "/repo/{channel_id}/{repo_id}/branch_protections/{policy_id}",
1314 tag = "repo",
14 request_body = EditBranchProtectionOption,
15 responses((status = 200, description = "Edit a branch protection", body = BranchProtectionView)),
15 request_body = AppRequestData<EditBranchProtectionOption>,
16 responses((status = 200, description = "Edit a branch protection", body = AppResponseData<BranchProtectionView>)),
1617 security(("bearer_auth" = []))
1718)]
1819pub(crate) async fn handler(
1920 State(svc): State<RepoService>,
2021 AuthUser { claims }: AuthUser,
2122 Path((_, repo_id, policy_id)): Path<(Uuid, Uuid, Uuid)>,
22 Json(input): Json<EditBranchProtectionOption>,
23) -> RepoResult<Json<BranchProtectionView>> {
23 input: AppRequest<EditBranchProtectionOption>,
24) -> RepoResult<AppResponseData<BranchProtectionView>> {
2425 let view = svc
25 .edit_branch_protection(claims.sub, repo_id, policy_id, input)
26 .edit_branch_protection(claims.sub, repo_id, policy_id, input.into_inner())
2627 .await?;
27 Ok(Json(view))
28 Ok(AppResponseData::ok(view))
2829}