From f9be9e406be233dcf1868c52c3d1f9867c8276fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E8=BF=90=E5=AE=B6?= Date: Fri, 12 Apr 2024 09:33:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8F=82=E6=95=B0=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 16 ++++++++++++++++ Cargo.lock | 6 ++++-- api/Cargo.toml | 1 + api/src/controller/game_account.rs | 7 +++++-- 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 .vscode/launch.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..ab6b3ba --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,16 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "lldb", + "request": "launch", + "name": "Debug", + "program": "${workspaceFolder}/target/debug/${workspaceFolderBasename}", + "args": [], + "cwd": "${workspaceFolder}" + } + ] +} \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 44718d3..4b59f04 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -82,6 +82,7 @@ name = "api" version = "0.1.0" dependencies = [ "axum", + "axum-extra", "domain", "library", "service", @@ -212,9 +213,9 @@ dependencies = [ [[package]] name = "axum-extra" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "895ff42f72016617773af68fb90da2a9677d89c62338ec09162d4909d86fdd8f" +checksum = "0be6ea09c9b96cb5076af0de2e383bd2bc0c18f827cf1967bdd353e0b910d733" dependencies = [ "axum", "axum-core", @@ -229,6 +230,7 @@ dependencies = [ "tower", "tower-layer", "tower-service", + "tracing", ] [[package]] diff --git a/api/Cargo.toml b/api/Cargo.toml index c0839fa..c863dd4 100644 --- a/api/Cargo.toml +++ b/api/Cargo.toml @@ -15,3 +15,4 @@ validator = { version = "0.17", features = ["derive"] } library = { path = "../library" } domain = { path = "../domain" } service = { path = "../service" } +axum-extra = "0.9.3" diff --git a/api/src/controller/game_account.rs b/api/src/controller/game_account.rs index eb65521..1d13870 100644 --- a/api/src/controller/game_account.rs +++ b/api/src/controller/game_account.rs @@ -1,9 +1,12 @@ use axum::Json; +use axum_extra::extract::WithRejection; use domain::dto::game_account::GameAccountCreate; -use library::resp::response::{ResErr, ResOK, ResResult}; +use library::resp::{rejection::IRejection, response::{ResErr, ResOK, ResResult}}; use validator::Validate; -pub async fn create(Json(req): Json) -> ResResult> { +pub async fn create( + WithRejection(Json(req), _): IRejection> +) -> ResResult> { if let Err(err) = req.validate() { return Err(ResErr::ErrParams(Some(err.to_string()))); }