Skip to content

Commit

Permalink
feat: Enable the CompressionLayer middleware (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabricedesre authored Sep 27, 2022
1 parent 21e7ab6 commit 9151fc1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion iroh-gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ iroh-resolver = { path = "../iroh-resolver" }
tokio-util = { version = "0.7", features = ["io"] }
bytes = "1.1.0"
tower-layer = { version = "0.3" }
tower-http = { version = "0.3", features = ["trace"] }
tower-http = { version = "0.3", features = ["trace", "compression-full"] }
http = "0.2"
async-recursion = "1.0.0"
handlebars = "4"
Expand Down
3 changes: 2 additions & 1 deletion iroh-gateway/src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use std::{
time::{self, Duration},
};
use tower::ServiceBuilder;
use tower_http::trace::TraceLayer;
use tower_http::{compression::CompressionLayer, trace::TraceLayer};
use tracing::info_span;
use url::Url;
use urlencoding::encode;
Expand Down Expand Up @@ -65,6 +65,7 @@ pub fn get_app_routes(state: &Arc<State>) -> Router {
ServiceBuilder::new()
// Handle errors from middleware
.layer(Extension(Arc::clone(state)))
.layer(CompressionLayer::new())
.layer(HandleErrorLayer::new(middleware_error_handler))
.load_shed()
.concurrency_limit(2048)
Expand Down

0 comments on commit 9151fc1

Please sign in to comment.