pub struct RateLimitContext {
pub store: Arc<dyn Store>,
pub jwt_config: Arc<JwtConfig>,
pub limiter: RateLimitState,
}Expand description
Context needed by the rate limit middleware.
Combines the limiter state with auth dependencies for identity extraction.
§Examples
use std::sync::Arc;
use ironflow_api::rate_limit::{RateLimitContext, per_minute};
use ironflow_auth::jwt::JwtConfig;
use ironflow_store::memory::InMemoryStore;
use ironflow_store::store::Store;
let store: Arc<dyn Store> = Arc::new(InMemoryStore::new());
let jwt_config = Arc::new(JwtConfig {
secret: "secret".to_string(),
access_token_ttl_secs: 900,
refresh_token_ttl_secs: 604800,
cookie_domain: None,
cookie_secure: false,
});
let ctx = RateLimitContext {
store,
jwt_config,
limiter: per_minute(60),
};Fields§
§store: Arc<dyn Store>Backing store for API key prefix lookups.
jwt_config: Arc<JwtConfig>JWT config for token decoding.
limiter: RateLimitStateThe rate limiter itself.
Trait Implementations§
Source§impl Clone for RateLimitContext
impl Clone for RateLimitContext
Source§fn clone(&self) -> RateLimitContext
fn clone(&self) -> RateLimitContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for RateLimitContext
impl !UnwindSafe for RateLimitContext
impl Freeze for RateLimitContext
impl Send for RateLimitContext
impl Sync for RateLimitContext
impl Unpin for RateLimitContext
impl UnsafeUnpin for RateLimitContext
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
Mutably borrows from an owned value. Read more