neon_arch commited on
Commit
7b1f93b
1 Parent(s): 1de52de

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

Browse files
Files changed (1) hide show
  1. src/lib.rs +7 -1
src/lib.rs CHANGED
@@ -14,7 +14,12 @@ use crate::server::routes;
14
 
15
  use actix_cors::Cors;
16
  use actix_files as fs;
17
- use actix_web::{dev::Server, http::header, middleware::Logger, web, App, HttpServer};
 
 
 
 
 
18
  use config::parser::Config;
19
  use handlebars::Handlebars;
20
  use handler::paths::{file_path, FileType};
@@ -68,6 +73,7 @@ pub fn run(listener: TcpListener, config: Config) -> std::io::Result<Server> {
68
  .app_data(web::Data::new(config.clone()))
69
  .wrap(cors)
70
  .wrap(Logger::default()) // added logging middleware for logging.
 
71
  // Serve images and static files (css and js files).
72
  .service(
73
  fs::Files::new("/static", format!("{}/static", public_folder_path))
 
14
 
15
  use actix_cors::Cors;
16
  use actix_files as fs;
17
+ use actix_web::{
18
+ dev::Server,
19
+ http::header,
20
+ middleware::{Compress, Logger},
21
+ web, App, HttpServer,
22
+ };
23
  use config::parser::Config;
24
  use handlebars::Handlebars;
25
  use handler::paths::{file_path, FileType};
 
73
  .app_data(web::Data::new(config.clone()))
74
  .wrap(cors)
75
  .wrap(Logger::default()) // added logging middleware for logging.
76
+ .wrap(Compress::default()) // compress request headers to reduce memory usage.
77
  // Serve images and static files (css and js files).
78
  .service(
79
  fs::Files::new("/static", format!("{}/static", public_folder_path))