use axum::Json; use axum::extract::{Path, State}; use export::rest::AppResponseData; use session::Session; use uuid::Uuid; use crate::errors::{ApiError, GitApiError}; use crate::handler::ensure_caller; use crate::service::GitService; use crate::service::repos::{CreateRepoCmd, RepoDto}; #[derive(Debug, Clone, serde::Deserialize, utoipa::IntoParams)] pub struct SpacePath { pub space_name: String, } #[utoipa::path( post, path = "/repos/{space_name}", tag = "repos", params(SpacePath), request_body = CreateRepoCmd, responses( (status = 200, description = "create repo", body = AppResponseData) ) )] pub async fn create_repo( State(service): State, session: Session, Path(path): Path, Json(cmd): Json, ) -> Result, ApiError> { let caller: Uuid = ensure_caller(&session)?; let out = service .create_repo(path.space_name, caller, cmd) .await .map_err(GitApiError::from)?; Ok(AppResponseData::ok(out)) }