Skip to content

Commit

Permalink
feat: add compression layer from axum/tower middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
Husni Zuhdi committed Dec 23, 2024
1 parent 7b6b535 commit 5d00d62
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
51 changes: 50 additions & 1 deletion 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 internal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ tokio = { version = "1.0", features = ["full"] }
tracing = { version = "0.1", features = ["attributes"] }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
tower = { version = "0.4", features = ["util"] }
tower-http = { version = "0.5.0", features = ["fs", "trace"] }
tower-http = { version = "0.5.0", features = ["fs", "trace", "compression-gzip"] }
askama = { version = "0.12.1"}
serde = { version="1.0.192", features = ["derive"]}
serde_json = "1.0.108"
Expand Down
3 changes: 3 additions & 0 deletions internal/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use axum::{
routing::{get, get_service},
Router,
};
use tower::ServiceBuilder;
use tower_http::compression::CompressionLayer;
use tower_http::services::{ServeDir, ServeFile};
use tracing::info;

Expand Down Expand Up @@ -37,6 +39,7 @@ pub async fn app() -> () {
get_service(ServeFile::new("./statics/styles.css")),
)
.with_state(app_state)
.layer(ServiceBuilder::new().layer(CompressionLayer::new()))
.fallback(get(handler::status::get_404_not_found));

// Start Axum Application
Expand Down

0 comments on commit 5d00d62

Please sign in to comment.