Skip to content

Commit 55c4126

Browse files
committed
refactor(api): add CompressionLayer for optimize api responses
1 parent ae974cd commit 55c4126

3 files changed

Lines changed: 78 additions & 3 deletions

File tree

Cargo.lock

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

rustmail/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ subtle = "2.6.1"
2727
sha2 = "0.10.8"
2828
hex = "0.4.3"
2929
moka = { version = "0.12", features = ["future"] }
30+
tower-http = { version = "0.6.7", features = ["compression-gzip", "compression-br"] }
3031

3132
[dependencies.uuid]
3233
version = "1.18.1"

rustmail/src/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use rust_embed::RustEmbed;
66
use std::borrow::Cow;
77
use std::net::SocketAddr;
88
use tokio::signal;
9+
use tower_http::compression::CompressionLayer;
910

1011
mod api;
1112
mod bot;
@@ -85,7 +86,8 @@ async fn main() {
8586
let server_task = tokio::spawn(async move {
8687
let app = create_api_router(bot_state_clone)
8788
.route("/", axum::routing::get(static_handler))
88-
.route("/{*path}", axum::routing::get(static_handler));
89+
.route("/{*path}", axum::routing::get(static_handler))
90+
.layer(CompressionLayer::new());
8991

9092
let bind_address = config
9193
.bot

0 commit comments

Comments
 (0)