pub struct ApiKeyLayer<A, S, C = ()> { /* private fields */ }
Expand description
Layer for API key validation and rate limiting
Implementations§
Source§impl<A, S> ApiKeyLayer<A, S, ()>where
A: ApiKeyStore + 'static,
S: BarnacleStore + 'static,
impl<A, S> ApiKeyLayer<A, S, ()>where
A: ApiKeyStore + 'static,
S: BarnacleStore + 'static,
pub fn new( api_key_store: Arc<A>, rate_limit_store: Arc<S>, config: ApiKeyMiddlewareConfig, ) -> Self
Source§impl<A, S, C> ApiKeyLayer<A, S, C>
impl<A, S, C> ApiKeyLayer<A, S, C>
Sourcepub fn new_with_custom_validator<NewC>(
api_key_store: Arc<A>,
rate_limit_store: Arc<S>,
config: ApiKeyMiddlewareConfig,
custom_validator: Arc<NewC>,
) -> ApiKeyLayer<A, S, NewC>where
NewC: ApiKeyStore + 'static,
pub fn new_with_custom_validator<NewC>(
api_key_store: Arc<A>,
rate_limit_store: Arc<S>,
config: ApiKeyMiddlewareConfig,
custom_validator: Arc<NewC>,
) -> ApiKeyLayer<A, S, NewC>where
NewC: ApiKeyStore + 'static,
Add a custom validator that will be used as fallback when the main api_key_store fails The custom validator will be called if the main store returns invalid, and if it returns valid, the key will be automatically cached in the main store for future requests
Trait Implementations§
Source§impl<A, S, C> Clone for ApiKeyLayer<A, S, C>
impl<A, S, C> Clone for ApiKeyLayer<A, S, C>
Source§impl<Inner, A, S> Layer<Inner> for ApiKeyLayer<A, S, ()>where
A: ApiKeyStore + 'static,
S: BarnacleStore + 'static,
impl<Inner, A, S> Layer<Inner> for ApiKeyLayer<A, S, ()>where
A: ApiKeyStore + 'static,
S: BarnacleStore + 'static,
Source§impl<Inner, A, S, C> Layer<Inner> for ApiKeyLayer<A, S, C>
impl<Inner, A, S, C> Layer<Inner> for ApiKeyLayer<A, S, C>
Auto Trait Implementations§
impl<A, S, C> Freeze for ApiKeyLayer<A, S, C>
impl<A, S, C> RefUnwindSafe for ApiKeyLayer<A, S, C>
impl<A, S, C> Send for ApiKeyLayer<A, S, C>
impl<A, S, C> Sync for ApiKeyLayer<A, S, C>
impl<A, S, C> Unpin for ApiKeyLayer<A, S, C>
impl<A, S, C> UnwindSafe for ApiKeyLayer<A, S, C>
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