Skip to content
Clone

refactor(repo): refresh branch_protection create handler

zhenyi committed
parent 878fd9a commit e234e62 Browse files

1 file changed

+8 −8

Modified lib/repo/handler/branch_protection/create.rs View lib/repo/handler/branch_protection/create.rs
@@ -1,6 +1,6 @@
1use axum::Json;
21use axum::extract::{Path, State};
3use axum::http::StatusCode;
2use export::data::{AppRequest, AppRequestData, AppResponseData};
3
44use jwt::extractor::AuthUser;
55use uuid::Uuid;
66
@@ -12,18 +12,18 @@
1212 post,
1313 path = "/repo/{channel_id}/{repo_id}/branch_protections",
1414 tag = "repo",
15 request_body = CreateBranchProtectionOption,
16 responses((status = 201, description = "Create a branch protection", body = BranchProtectionView)),
15 request_body = AppRequestData<CreateBranchProtectionOption>,
16 responses((status = 201, description = "Create a branch protection", body = AppResponseData<BranchProtectionView>)),
1717 security(("bearer_auth" = []))
1818)]
1919pub(crate) async fn handler(
2020 State(svc): State<RepoService>,
2121 AuthUser { claims }: AuthUser,
2222 Path((_, repo_id)): Path<(Uuid, Uuid)>,
23 Json(input): Json<CreateBranchProtectionOption>,
24) -> RepoResult<(StatusCode, Json<BranchProtectionView>)> {
23 input: AppRequest<CreateBranchProtectionOption>,
24) -> RepoResult<AppResponseData<BranchProtectionView>> {
2525 let view = svc
26 .create_branch_protection(claims.sub, repo_id, input)
26 .create_branch_protection(claims.sub, repo_id, input.into_inner())
2727 .await?;
28 Ok((StatusCode::CREATED, Json(view)))
28 Ok(AppResponseData::ok(view).with_code(201))
2929}