From 5bfba3a87afbf4157c2b0bd36273e3dcc4075578 Mon Sep 17 00:00:00 2001 From: Bryan Stitt Date: Fri, 6 Jan 2023 14:22:57 -0800 Subject: [PATCH] cargo upgrade and use trailing slash route extra --- Cargo.lock | 28 ++++++++++++++++++++++++---- deferred-rate-limiter/Cargo.toml | 2 +- migration/Cargo.toml | 2 +- redis-rate-limiter/Cargo.toml | 2 +- web3_proxy/Cargo.toml | 5 +++-- web3_proxy/src/frontend/mod.rs | 13 +++---------- web3_proxy/src/frontend/status.rs | 1 - 7 files changed, 33 insertions(+), 20 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e106b51b..3f62b429 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -405,6 +405,25 @@ dependencies = [ "tower-service", ] +[[package]] +name = "axum-extra" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9a320103719de37b7b4da4c8eb629d4573f6bcfd3dfe80d3208806895ccf81d" +dependencies = [ + "axum", + "bytes", + "futures-util", + "http", + "mime", + "pin-project-lite", + "tokio", + "tower", + "tower-http", + "tower-layer", + "tower-service", +] + [[package]] name = "axum-macros" version = "0.3.0" @@ -2061,9 +2080,9 @@ checksum = "78cc372d058dcf6d5ecd98510e7fbc9e5aec4d21de70f65fea8fecebcd881bd4" [[package]] name = "glob" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "group" @@ -4983,9 +5002,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.23.1" +version = "1.24.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38a54aca0c15d014013256222ba0ebed095673f89345dd79119d912eb561b7a8" +checksum = "1d9f76183f91ecfb55e1d7d5602bd1d979e38a3a522fe900241cf195624d67ae" dependencies = [ "autocfg", "bytes", @@ -5536,6 +5555,7 @@ dependencies = [ "argh", "axum", "axum-client-ip", + "axum-extra", "axum-macros", "chrono", "counter", diff --git a/deferred-rate-limiter/Cargo.toml b/deferred-rate-limiter/Cargo.toml index 81dad0d6..e5ee532a 100644 --- a/deferred-rate-limiter/Cargo.toml +++ b/deferred-rate-limiter/Cargo.toml @@ -11,4 +11,4 @@ anyhow = "1.0.68" hashbrown = "0.13.1" log = "0.4.17" moka = { version = "0.9.6", default-features = false, features = ["future"] } -tokio = "1.23.1" +tokio = "1.24.1" diff --git a/migration/Cargo.toml b/migration/Cargo.toml index 62cbdc8a..fd1e4a12 100644 --- a/migration/Cargo.toml +++ b/migration/Cargo.toml @@ -9,7 +9,7 @@ name = "migration" path = "src/lib.rs" [dependencies] -tokio = { version = "1.23.1", features = ["full", "tracing"] } +tokio = { version = "1.24.1", features = ["full", "tracing"] } [dependencies.sea-orm-migration] version = "0.10.6" diff --git a/redis-rate-limiter/Cargo.toml b/redis-rate-limiter/Cargo.toml index 3c81d19a..fcc05372 100644 --- a/redis-rate-limiter/Cargo.toml +++ b/redis-rate-limiter/Cargo.toml @@ -7,4 +7,4 @@ edition = "2021" [dependencies] anyhow = "1.0.68" deadpool-redis = { version = "0.11.1", features = ["rt_tokio_1", "serde"] } -tokio = "1.23.1" +tokio = "1.24.1" diff --git a/web3_proxy/Cargo.toml b/web3_proxy/Cargo.toml index f1a29895..c90d486f 100644 --- a/web3_proxy/Cargo.toml +++ b/web3_proxy/Cargo.toml @@ -60,7 +60,7 @@ serde_json = { version = "1.0.91", default-features = false, features = ["alloc" serde_prometheus = "0.1.6" # TODO: make sure this time version matches siwe. PR to put this in their prelude time = "0.3.17" -tokio = { version = "1.23.1", features = ["full"] } +tokio = { version = "1.24.1", features = ["full"] } # TODO: make sure this uuid version matches sea-orm. PR to put this in their prelude tokio-stream = { version = "0.1.11", features = ["sync"] } toml = "0.5.10" @@ -70,4 +70,5 @@ ulid = { version = "1.0.0", features = ["serde"] } url = "2.3.1" uuid = "1.2.2" itertools = "0.10.5" -glob = "0.3.0" +glob = "0.3.1" +axum-extra = "0.4.2" diff --git a/web3_proxy/src/frontend/mod.rs b/web3_proxy/src/frontend/mod.rs index 4d94367c..da022e7a 100644 --- a/web3_proxy/src/frontend/mod.rs +++ b/web3_proxy/src/frontend/mod.rs @@ -13,6 +13,7 @@ use axum::{ routing::{get, post, put}, Extension, Router, }; +use axum_extra::routing::RouterExt; use http::header::AUTHORIZATION; use log::info; use moka::future::Cache; @@ -45,22 +46,14 @@ pub async fn serve(port: u16, proxy_app: Arc) -> anyhow::Result<() // routes should be ordered most to least common .route("/", post(rpc_proxy_http::proxy_web3_rpc)) .route("/", get(rpc_proxy_ws::websocket_handler)) - .route( + .route_with_tsr( "/rpc/:rpc_key", post(rpc_proxy_http::proxy_web3_rpc_with_key), ) - .route( - "/rpc/:rpc_key/", - post(rpc_proxy_http::proxy_web3_rpc_with_key), - ) - .route( + .route_with_tsr( "/rpc/:rpc_key", get(rpc_proxy_ws::websocket_handler_with_key), ) - .route( - "/rpc/:rpc_key/", - get(rpc_proxy_ws::websocket_handler_with_key), - ) .route("/health", get(status::health)) .route("/user/login/:user_address", get(users::user_login_get)) .route( diff --git a/web3_proxy/src/frontend/status.rs b/web3_proxy/src/frontend/status.rs index 714dab9e..2e4a8198 100644 --- a/web3_proxy/src/frontend/status.rs +++ b/web3_proxy/src/frontend/status.rs @@ -7,7 +7,6 @@ use super::{FrontendResponseCache, FrontendResponseCaches}; use crate::app::Web3ProxyApp; use axum::{http::StatusCode, response::IntoResponse, Extension, Json}; use axum_macros::debug_handler; -use moka::future::ConcurrentCacheExt; use serde_json::json; use std::sync::Arc;