From dbe36bfbaf588b5543b94569337533d4e5d629a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=BF=90=E5=AE=B6?= Date: Mon, 30 Sep 2024 18:05:15 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=97=A0=E7=94=A8=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/controller/todo.rs | 54 ----------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 server/src/controller/todo.rs diff --git a/server/src/controller/todo.rs b/server/src/controller/todo.rs deleted file mode 100644 index c692447..0000000 --- a/server/src/controller/todo.rs +++ /dev/null @@ -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(pub T); - -// #[async_trait] -// impl FromRequest for Validated -// where -// S: Send + Sync, -// B: Send + 'static, -// T: Validate, -// Query: FromRequestParts, -// { -// type Rejection = (http::StatusCode, String); - -// async fn from_request(req: http::Request, state: &S) -> Result { -// let query = Query::::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, -// ) -> response::Json { -// response::Json(pagination) -// } \ No newline at end of file