use axum::Json; use axum::extract::{Path, State}; use export::rest::AppResponseData; use session::Session; use crate::errors::{ApiError, GitApiError}; use crate::handler::require_writer; use crate::service::branches::{BranchDto, CreateBranchCmd}; use crate::service::GitService; pub async fn create_branch( State(service): State, session: Session, Path(path): Path, Json(cmd): Json, ) -> Result, ApiError> { let _ = require_writer(&service, &session, path.space_name.clone(), path.repo_name.clone()).await?; let out = service .create_branch(path.space_name, path.repo_name, cmd) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(out)) }