From 7b1f93b232f7ed8a1fb82a3cbe9fea4c6181910b Mon Sep 17 00:00:00 2001 From: neon_arch Date: Tue, 29 Aug 2023 20:12:15 +0300 Subject: [PATCH] =?UTF-8?q?=E2=9A=99=EF=B8=8F=20refactor:=20add=20compress?= =?UTF-8?q?=20middleware=20to=20reduce=20memory=20usage=20(#180)(#178)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index e76344b..97bff01 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,12 @@ use crate::server::routes; use actix_cors::Cors; use actix_files as fs; -use actix_web::{dev::Server, http::header, middleware::Logger, web, App, HttpServer}; +use actix_web::{ + dev::Server, + http::header, + middleware::{Compress, Logger}, + web, App, HttpServer, +}; use config::parser::Config; use handlebars::Handlebars; use handler::paths::{file_path, FileType}; @@ -68,6 +73,7 @@ pub fn run(listener: TcpListener, config: Config) -> std::io::Result { .app_data(web::Data::new(config.clone())) .wrap(cors) .wrap(Logger::default()) // added logging middleware for logging. + .wrap(Compress::default()) // compress request headers to reduce memory usage. // Serve images and static files (css and js files). .service( fs::Files::new("/static", format!("{}/static", public_folder_path))