use axum::extract::{FromRequestParts, Path}; use axum::http::request::Parts; use serde::Deserialize; use utoipa::IntoParams; use crate::errors::ApiError; #[derive(Debug, Clone, Deserialize, IntoParams)] pub struct PullPath { pub space_name: String, pub repo_name: String, /// PR 编号(`12`)或 UUID。 pub pull_ref: String, } impl FromRequestParts for PullPath where S: Send + Sync, { type Rejection = ApiError; async fn from_request_parts(parts: &mut Parts, state: &S) -> Result { Path::::from_request_parts(parts, state) .await .map(|Path(p)| p) .map_err(|_| { ApiError::BadRequest(export::rest::AppResponseData::err( 400, "invalid request path", )) }) } }