From a43e9553f16a3d8dcc486b4666f55bfaeb20f5ba Mon Sep 17 00:00:00 2001 From: Danil Date: Thu, 18 Jan 2024 14:49:34 +0100 Subject: [PATCH] fix: change types on api (#358) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # What ❔ ## Why ❔ ## Checklist - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `cargo fmt`. Signed-off-by: Danil --- api/src/lib.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/api/src/lib.rs b/api/src/lib.rs index 2540c283..a1410b9f 100644 --- a/api/src/lib.rs +++ b/api/src/lib.rs @@ -1,4 +1,4 @@ -use axum::extract::State; +use axum::extract::{Path, Query, State}; use axum::{http::StatusCode, routing::get, Json, Router}; use ethers::abi::Address; use ethers::types::{H256, U256}; @@ -8,7 +8,6 @@ use storage::UserWithdrawal; #[derive(Deserialize, Serialize, Clone)] struct WithdrawalRequest { - pub from: Address, pub limit: u64, } #[derive(Deserialize, Serialize, Clone)] @@ -32,7 +31,7 @@ impl From for WithdrawalResponse { pub async fn run_server(pool: PgPool) { let app = Router::new() - .route("/withdrawals", get(get_withdrawals)) + .route("/withdrawals/:from", get(get_withdrawals)) .with_state(pool); // run our app with hyper, listening globally on port 3000 @@ -41,10 +40,11 @@ pub async fn run_server(pool: PgPool) { } async fn get_withdrawals( + Path(from): Path
, State(pool): State, - Json(payload): Json, + Query(payload): Query, ) -> Result>, StatusCode> { - let result: Vec<_> = storage::withdrawals_for_address(&pool, payload.from, payload.limit) + let result: Vec<_> = storage::withdrawals_for_address(&pool, from, payload.limit) .await .map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)? .into_iter()