a06673b
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::{ContentsResponse, UpdateFileOption};
#[utoipa::path(
put,
path = "/repo/{channel_id}/{repo_id}/contents/{path}",
tag = "repo",
request_body = UpdateFileOption,
responses((status = 200, description = "Update a file", body = ContentsResponse)),
security(("bearer_auth" = []))
)]
pub(crate) async fn handler(
State(svc): State<RepoService>,
AuthUser { claims }: AuthUser,
Path((_, repo_id, path)): Path<(Uuid, Uuid, String)>,
Json(input): Json<UpdateFileOption>,
) -> RepoResult<Json<ContentsResponse>> {
let resp = svc.update_file(claims.sub, repo_id, &path, input).await?;
Ok(Json(resp))
}