summaryrefslogtreecommitdiffstats
path: root/server/src/rate_limit/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/rate_limit/mod.rs')
-rw-r--r--server/src/rate_limit/mod.rs25
1 files changed, 10 insertions, 15 deletions
diff --git a/server/src/rate_limit/mod.rs b/server/src/rate_limit/mod.rs
index fec8a569..b4c2dc5d 100644
--- a/server/src/rate_limit/mod.rs
+++ b/server/src/rate_limit/mod.rs
@@ -1,23 +1,18 @@
-pub mod rate_limiter;
-
use super::{IPAddr, Settings};
-use crate::api::APIError;
-use crate::get_ip;
-use crate::settings::RateLimitConfig;
+use crate::{api::APIError, get_ip, settings::RateLimitConfig};
use actix_web::dev::{Service, ServiceRequest, ServiceResponse, Transform};
-use failure::Error;
use futures::future::{ok, Ready};
-use log::debug;
use rate_limiter::{RateLimitType, RateLimiter};
-use std::collections::HashMap;
-use std::future::Future;
-use std::pin::Pin;
-use std::sync::Arc;
-use std::task::{Context, Poll};
-use std::time::SystemTime;
-use strum::IntoEnumIterator;
+use std::{
+ future::Future,
+ pin::Pin,
+ sync::Arc,
+ task::{Context, Poll},
+};
use tokio::sync::Mutex;
+pub mod rate_limiter;
+
#[derive(Debug, Clone)]
pub struct RateLimit {
pub rate_limiter: Arc<Mutex<RateLimiter>>,
@@ -92,7 +87,7 @@ impl RateLimited {
}
RateLimitType::Post => {
limiter.check_rate_limit_full(
- self.type_.clone(),
+ self.type_,
&ip_addr,
rate_limit.post,
rate_limit.post_per_second,