pub struct ApiKeyAuth { /* private fields */ }Implementations§
Source§impl ApiKeyAuth
impl ApiKeyAuth
Sourcepub fn new(key: impl Into<String>) -> Self
pub fn new(key: impl Into<String>) -> Self
Creates authentication middleware with a single static API key.
By default, the key is extracted from the X-API-Key header.
Sourcepub fn from_keys<I>(keys: I) -> Self
pub fn from_keys<I>(keys: I) -> Self
Creates authentication middleware with multiple static API keys.
Sourcepub fn with_verify<F>(f: F) -> Self
pub fn with_verify<F>(f: F) -> Self
Creates authentication middleware with a custom verification function.
Sourcepub fn from_keys_with_verify<I, F>(keys: I, f: F) -> Self
pub fn from_keys_with_verify<I, F>(keys: I, f: F) -> Self
Creates authentication with both static keys and custom verification.
Sourcepub fn location(self, location: ApiKeyLocation) -> Self
pub fn location(self, location: ApiKeyLocation) -> Self
Sets the location where the API key should be extracted from.
Sourcepub fn header_name(self, name: &'static str) -> Self
pub fn header_name(self, name: &'static str) -> Self
Sets a custom header name for API key extraction.
This is a convenience method equivalent to
.location(ApiKeyLocation::Header(name)).
Sourcepub fn query_param(self, name: &'static str) -> Self
pub fn query_param(self, name: &'static str) -> Self
Sets a query parameter name for API key extraction.
This is a convenience method equivalent to
.location(ApiKeyLocation::Query(name)).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ApiKeyAuth
impl !RefUnwindSafe for ApiKeyAuth
impl Send for ApiKeyAuth
impl Sync for ApiKeyAuth
impl Unpin for ApiKeyAuth
impl UnsafeUnpin for ApiKeyAuth
impl !UnwindSafe for ApiKeyAuth
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