diff --git a/server/service/src/main.rs b/server/service/src/main.rs index fc2486c..6d76067 100644 --- a/server/service/src/main.rs +++ b/server/service/src/main.rs @@ -28,7 +28,7 @@ const RATE_LIMIT_PER_SECOND: i32 = 60; pub struct State { rate_limits: Mutex>, - pool: r2d2::Pool, + pool: Mutex>, } #[derive(Debug)] @@ -45,7 +45,7 @@ fn main() { let shared_data = web::Data::new(State { rate_limits: Mutex::new(HashMap::new()), - pool: pool, + pool: Mutex::new(pool), }); HttpServer::new(move || { @@ -106,7 +106,7 @@ fn search( .body(format!("{{\"error\": \"{}\"}}", "Empty query".to_string())); } - let conn = data.pool.get().unwrap(); + let conn = data.pool.lock().unwrap().get().unwrap(); match check_rate_limit_full(data, &ip, RATE_LIMIT, RATE_LIMIT_PER_SECOND) { Ok(_) => HttpResponse::Ok()