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