Skip to content
Clone
a06673b
26 lines 842 B Rust
use axum::Json;
use axum::extract::{Path, State};
use jwt::extractor::AuthUser;
use uuid::Uuid;
use crate::error::RepoResult;
use crate::features::RepoService;
use crate::features::contents::{ApplyDiffPatchFileOptions, ContentsResponse};
#[utoipa::path(
post,
path = "/repo/{channel_id}/{repo_id}/diffpatch",
tag = "repo",
request_body = ApplyDiffPatchFileOptions,
responses((status = 200, description = "Apply a diff patch", body = ContentsResponse)),
security(("bearer_auth" = []))
)]
pub(crate) async fn handler(
State(svc): State<RepoService>,
AuthUser { claims }: AuthUser,
Path((_, repo_id)): Path<(Uuid, Uuid)>,
Json(input): Json<ApplyDiffPatchFileOptions>,
) -> RepoResult<Json<ContentsResponse>> {
let resp = svc.apply_diff_patch(claims.sub, repo_id, input).await?;
Ok(Json(resp))
}