移除无用代码

This commit is contained in:
李运家 2024-09-30 18:05:15 +08:00
parent d002c68fc2
commit dbe36bfbaf

View File

@ -1,54 +0,0 @@
// https://github.com/tokio-rs/axum/discussions/2081
// use axum::{
// async_trait,
// extract::{FromRequest, FromRequestParts, Query},
// http, response,
// };
// use serde::{Deserialize, Serialize};
// use validator::Validate;
// pub struct Validated<T>(pub T);
// #[async_trait]
// impl<S, B, T> FromRequest<S, B> for Validated<T>
// where
// S: Send + Sync,
// B: Send + 'static,
// T: Validate,
// Query<T>: FromRequestParts<S>,
// {
// type Rejection = (http::StatusCode, String);
// async fn from_request(req: http::Request<B>, state: &S) -> Result<Self, Self::Rejection> {
// let query = Query::<T>::from_request(req, state).await;
// if let Ok(Query(data)) = query {
// match data.validate() {
// Ok(_) => Ok(Validated(data)),
// Err(err) => Err((http::StatusCode::BAD_REQUEST, err.to_string())),
// }
// } else {
// Err((
// http::StatusCode::INTERNAL_SERVER_ERROR,
// "internal server error".to_string(),
// ))
// }
// }
// }
// // my handler
// #[derive(Deserialize, Serialize, Validate)]
// pub struct Pagination {
// #[validate(range(min = 1))]
// page: usize,
// #[validate(range(max = 100))]
// per_page: usize,
// }
// #[axum::debug_handler]
// pub async fn get_query_string(
// Validated(pagination): Validated<Pagination>,
// ) -> response::Json<Pagination> {
// response::Json(pagination)
// }