mirror of
https://github.com/neon-mmd/websurfx.git
synced 2024-12-22 20:38:22 -05:00
✨ feat: pass the new config option into the middleware config (#203)
This commit is contained in:
parent
8cba040d80
commit
51937a0d49
10
src/lib.rs
10
src/lib.rs
@ -14,6 +14,7 @@ use crate::server::routes;
|
||||
|
||||
use actix_cors::Cors;
|
||||
use actix_files as fs;
|
||||
use actix_governor::{Governor, GovernorConfigBuilder};
|
||||
use actix_web::{dev::Server, http::header, middleware::Logger, web, App, HttpServer};
|
||||
use config::parser::Config;
|
||||
use handlebars::Handlebars;
|
||||
@ -64,10 +65,17 @@ pub fn run(listener: TcpListener, config: Config) -> std::io::Result<Server> {
|
||||
]);
|
||||
|
||||
App::new()
|
||||
.wrap(Logger::default()) // added logging middleware for logging.
|
||||
.app_data(handlebars_ref.clone())
|
||||
.app_data(web::Data::new(config.clone()))
|
||||
.wrap(cors)
|
||||
.wrap(Logger::default()) // added logging middleware for logging.
|
||||
.wrap(Governor::new(
|
||||
&GovernorConfigBuilder::default()
|
||||
.per_second(config.rate_limter.time_limit as u64)
|
||||
.burst_size(config.rate_limter.number_of_requests as u32)
|
||||
.finish()
|
||||
.unwrap(),
|
||||
))
|
||||
// Serve images and static files (css and js files).
|
||||
.service(
|
||||
fs::Files::new("/static", format!("{}/static", public_folder_path))
|
||||
|
Loading…
Reference in New Issue
Block a user