pub struct ApiKeyLayer { /* private fields */ }Expand description
Tower Layer that verifies API keys on incoming requests.
Reads the raw token from the Authorization: Bearer <token> header
(or a custom header), calls ApiKeyStore::verify, and inserts
super::ApiKeyMeta into request extensions on success.
Errors are returned as crate::Error – the app’s error handler
decides rendering.
Implementations§
Source§impl ApiKeyLayer
impl ApiKeyLayer
Sourcepub fn new(store: ApiKeyStore) -> Self
pub fn new(store: ApiKeyStore) -> Self
Create a layer that reads from Authorization: Bearer <token>.
Sourcepub fn from_header(store: ApiKeyStore, header: &str) -> Result<Self>
pub fn from_header(store: ApiKeyStore, header: &str) -> Result<Self>
Create a layer that reads from a custom header.
§Errors
Returns Error::bad_request if the header name is invalid.
Trait Implementations§
Source§impl Clone for ApiKeyLayer
impl Clone for ApiKeyLayer
Auto Trait Implementations§
impl !Freeze for ApiKeyLayer
impl !RefUnwindSafe for ApiKeyLayer
impl Send for ApiKeyLayer
impl Sync for ApiKeyLayer
impl Unpin for ApiKeyLayer
impl UnsafeUnpin for ApiKeyLayer
impl !UnwindSafe for ApiKeyLayer
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