Skip to content

Commit

Permalink
torrust#262: Add tower-http compression middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
alexohneander committed Aug 26, 2023
1 parent 79ff3cc commit bf3f66f
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 4 deletions.
42 changes: 40 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ thiserror = "1.0"
binascii = "0.1"
axum = { version = "0.6.18", features = ["multipart"] }
hyper = "0.14.26"
tower-http = { version = "0.4.0", features = ["cors"] }
tower-http = { version = "0.4.0", features = ["cors", "compression-full"] }
email_address = "0.2.4"
hex = "0.4.3"
uuid = { version = "1.3", features = ["v4"] }
Expand Down
3 changes: 2 additions & 1 deletion src/web/api/v1/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use std::sync::Arc;
use axum::extract::DefaultBodyLimit;
use axum::routing::get;
use axum::Router;
use tower_http::compression::CompressionLayer;
use tower_http::cors::CorsLayer;

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

router.layer(DefaultBodyLimit::max(10_485_760))
router.layer(DefaultBodyLimit::max(10_485_760)).layer(CompressionLayer::new())
}

0 comments on commit bf3f66f

Please sign in to comment.