pub struct SimpleInputFunctionBuilder { /* private fields */ }
Expand description
Utility to create a input function that produces a SimpleInput.
You should take care to ensure that you are producing unique keys per backend.
This will not be of any use if you want to use dynamic interval/request policies or perform an asynchronous option; you should instead write your own input function.
Implementations§
Source§impl SimpleInputFunctionBuilder
impl SimpleInputFunctionBuilder
pub fn new(interval: Duration, max_requests: u64) -> Self
Sourcepub fn real_ip_key(self) -> Self
pub fn real_ip_key(self) -> Self
Adds the client’s real IP to the rate limiting key.
§Security
This calls ConnectionInfo::realip_remote_addr() internally which is only suitable for Actix applications deployed behind a proxy that you control.
§IPv6
IPv6 addresses will be grouped into a single key per /64
Sourcepub fn peer_ip_key(self) -> Self
pub fn peer_ip_key(self) -> Self
Adds the connection peer IP to the rate limiting key.
This is suitable when clients connect directly to the Actix application.
§IPv6
IPv6 addresses will be grouped into a single key per /64
Sourcepub fn custom_key(self, key: &str) -> Self
pub fn custom_key(self, key: &str) -> Self
Add a custom component to the rate limiting key
Sourcepub fn custom_fn<F>(self, f: F) -> Self
pub fn custom_fn<F>(self, f: F) -> Self
Dynamically add a custom component to the rate limiting key
pub fn build(self) -> impl Fn(&ServiceRequest) -> SimpleInputFuture + 'static
Auto Trait Implementations§
impl Freeze for SimpleInputFunctionBuilder
impl !RefUnwindSafe for SimpleInputFunctionBuilder
impl !Send for SimpleInputFunctionBuilder
impl !Sync for SimpleInputFunctionBuilder
impl Unpin for SimpleInputFunctionBuilder
impl !UnwindSafe for SimpleInputFunctionBuilder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more