aboutsummaryrefslogtreecommitdiff
path: root/planetwars-server
diff options
context:
space:
mode:
authorIlion Beyst <ilion.beyst@gmail.com>2022-10-10 13:23:18 +0200
committerIlion Beyst <ilion.beyst@gmail.com>2022-10-10 13:23:18 +0200
commitf7eedc6ca1156ed5c29bfef503c233f2aaa1ad48 (patch)
tree8b894e6fc4528a1427d4d142af2aca85f12235f4 /planetwars-server
parent505ea6a23d1084966ea24890868af60ab5e357da (diff)
downloadplanetwars.dev-f7eedc6ca1156ed5c29bfef503c233f2aaa1ad48.tar.xz
planetwars.dev-f7eedc6ca1156ed5c29bfef503c233f2aaa1ad48.zip
enable request & response compression
Diffstat (limited to 'planetwars-server')
-rw-r--r--planetwars-server/Cargo.toml1
-rw-r--r--planetwars-server/src/lib.rs2
2 files changed, 3 insertions, 0 deletions
diff --git a/planetwars-server/Cargo.toml b/planetwars-server/Cargo.toml
index 6fb46d5..f5641d1 100644
--- a/planetwars-server/Cargo.toml
+++ b/planetwars-server/Cargo.toml
@@ -18,6 +18,7 @@ futures = "0.3"
tokio = { version = "1.15", features = ["full"] }
tokio-stream = "0.1.9"
hyper = "0.14"
+tower-http = { version = "0.3.4", features = ["full"] }
axum = { version = "0.5", features = ["json", "headers", "multipart"] }
diesel = { version = "1.4.4", features = ["postgres", "chrono"] }
diesel-derive-enum = { version = "1.1", features = ["postgres"] }
diff --git a/planetwars-server/src/lib.rs b/planetwars-server/src/lib.rs
index 1301adb..62bf198 100644
--- a/planetwars-server/src/lib.rs
+++ b/planetwars-server/src/lib.rs
@@ -29,6 +29,7 @@ use axum::{
routing::{get, post},
Router,
};
+use tower_http::compression::CompressionLayer;
type ConnectionPool = bb8::Pool<DieselConnectionManager<PgConnection>>;
@@ -147,6 +148,7 @@ pub fn create_pw_api(global_config: Arc<GlobalConfig>, db_pool: DbPool) -> Route
.nest("/api", api())
.layer(Extension(db_pool))
.layer(Extension(global_config))
+ .layer(CompressionLayer::new())
}
pub fn get_config() -> Result<GlobalConfig, ConfigError> {