0
0
mirror of https://github.com/neon-mmd/websurfx.git synced 2024-11-22 05:58:21 -05:00

⚙️ refactor: add compress middleware to reduce memory usage (#180)(#178)

This commit is contained in:
neon_arch 2023-08-29 20:12:15 +03:00
parent 1de52decd3
commit 7b1f93b232

View File

@ -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<Server> {
.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))