Skip to content

Commit 1e3d23c

Browse files
committed
🔖 Release v0.2.1
1 parent eca8b44 commit 1e3d23c

3 files changed

Lines changed: 127 additions & 34 deletions

File tree

Cargo.lock

Lines changed: 112 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
11
[package]
22
name = "elex-proxy"
3-
version = "0.2.0"
3+
version = "0.2.1"
44
edition = "2021"
55
build = "build.rs"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
99
axum = { version = "^0.7.5", features = ["http2"] }
1010
futures = "^0"
11-
serde = { version = "^1.0.197", features = ["derive"] }
12-
serde_json = "^1.0.115"
11+
serde = { version = "^1", features = ["derive"] }
12+
serde_json = "^1"
1313
tokio = { version = "^1.37.0", features = ["full"] }
1414
tokio-stream = "^0.1.15"
1515
tungstenite = "^0"
1616
tokio-tungstenite = { version = "^0", features = ["native-tls"] }
1717
openssl = { version = "^0.10.64", features = ["vendored"] }
1818
url = "^2"
19-
time = { version = "^0.3.34", features = [] }
19+
time = { version = "^0.3", features = [] }
2020
tower = { version = "^0", features = ["full"] }
21-
tower-http = { version = "^0.5.2", features = ["cors", "trace", "catch-panic"] }
21+
tower-http = { version = "^0.5.2", features = ["cors", "trace", "catch-panic", "compression-br", "async-compression", "tokio"] }
2222
once_cell = "^1"
2323
tracing = "^0"
2424
tracing-subscriber = "^0"
25-
anyhow = "^1.0.81"
26-
tower_governor = "^0.3.2"
25+
anyhow = "^1"
26+
tower_governor = "0.4.2"
2727
bytes = "^1.6.0"
2828
http-body-util = "^0.1.1"
2929
dotenv = "^0"
3030
regex = "^1.10.4"
3131
headers = "0.4.0"
3232
forwarded-header-value = "0.1.1"
3333
rand = "0.8.5"
34-
bitcoin = "0.31.2"
34+
bitcoin = "0.32.0"
3535
hex = "0.4.3"
36-
moka = { version = "0.12.5", features = ["future"] }
36+
moka = { version = "0.12", features = ["future"] }
3737
ciborium = "0.2.2"
3838
mime_guess = "2.0.4"
3939

4040
[build-dependencies]
4141
vergen = { version = "9.0.0-beta.2", features = ["build", "cargo", "rustc"] }
42-
anyhow = "^1.0.81"
42+
anyhow = "^1"
4343

4444
[profile.release]
4545
strip = true

src/main.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ use tower_governor::governor::GovernorConfigBuilder;
3636
use tower_governor::key_extractor::SmartIpKeyExtractor;
3737
use tower_governor::GovernorLayer;
3838
use tower_http::catch_panic::CatchPanicLayer;
39+
use tower_http::compression::CompressionLayer;
3940
use tower_http::cors::CorsLayer;
4041
use tower_http::trace::TraceLayer;
42+
use tower_http::CompressionLevel;
4143
use tracing::{debug, error, info, warn};
4244

4345
use crate::cache::to_cache_key;
@@ -256,7 +258,7 @@ fn handle_panic(err: Box<dyn Any + Send + 'static>) -> http::Response<Full<Bytes
256258
async fn main() {
257259
dotenv().ok();
258260
tracing_subscriber::fmt::init();
259-
let governor_conf = Box::new(
261+
let governor_conf = Arc::new(
260262
GovernorConfigBuilder::default()
261263
.per_millisecond(*IP_LIMIT_PER_MILLS)
262264
.burst_size(*IP_LIMIT_BURST_SIZE)
@@ -292,8 +294,9 @@ async fn main() {
292294
.route("/proxy/health", get(handle_health).post(handle_health))
293295
.route("/proxy/:method", get(handle_get).post(handle_post))
294296
.layer(GovernorLayer {
295-
config: Box::leak(governor_conf),
297+
config: governor_conf,
296298
})
299+
.layer(CompressionLayer::new().quality(CompressionLevel::Best))
297300
.layer(ConcurrencyLimitLayer::new(*CONCURRENCY_LIMIT))
298301
.layer(CatchPanicLayer::custom(handle_panic))
299302
.layer(TraceLayer::new_for_http())

0 commit comments

Comments
 (0)