Skip to content

Commit bf3f66f

Browse files
committed
#262: Add tower-http compression middleware
1 parent 79ff3cc commit bf3f66f

File tree

3 files changed

+43
-4
lines changed

3 files changed

+43
-4
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ thiserror = "1.0"
7272
binascii = "0.1"
7373
axum = { version = "0.6.18", features = ["multipart"] }
7474
hyper = "0.14.26"
75-
tower-http = { version = "0.4.0", features = ["cors"] }
75+
tower-http = { version = "0.4.0", features = ["cors", "compression-full"] }
7676
email_address = "0.2.4"
7777
hex = "0.4.3"
7878
uuid = { version = "1.3", features = ["v4"] }

src/web/api/v1/routes.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::sync::Arc;
55
use axum::extract::DefaultBodyLimit;
66
use axum::routing::get;
77
use axum::Router;
8+
use tower_http::compression::CompressionLayer;
89
use tower_http::cors::CorsLayer;
910

1011
use super::contexts::about::handlers::about_page_handler;
@@ -42,5 +43,5 @@ pub fn router(app_data: Arc<AppData>) -> Router {
4243
router
4344
};
4445

45-
router.layer(DefaultBodyLimit::max(10_485_760))
46+
router.layer(DefaultBodyLimit::max(10_485_760)).layer(CompressionLayer::new())
4647
}

0 commit comments

Comments
 (0)