pub struct Method<E> { /* private fields */ }Expand description
Extracts the HTTP method as a cache key part.
Adds a key part with name "method" and the method as value (e.g., "GET", "POST").
Use this as the starting point for extractor chains.
§Type Parameters
E- The inner extractor to chain with. UseMethod::newto start a new extractor chain (usesNeutralExtractorinternally), or use theMethodExtractorextension trait to chain onto an existing extractor.
§Examples
use hitbox_http::extractors::{Method, path::PathExtractor, query::QueryExtractor};
let extractor = Method::new()
.path("/users/{user_id}")
.query("page".to_string());§Key Parts Generated
Generates a single key part: method={METHOD} where {METHOD} is the
uppercase HTTP method name (GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS, etc.).
Implementations§
Source§impl<S> Method<NeutralExtractor<S>>
impl<S> Method<NeutralExtractor<S>>
Sourcepub fn new() -> Method<NeutralExtractor<S>>
pub fn new() -> Method<NeutralExtractor<S>>
Creates a method extractor as the starting point for cache key generation.
Adds a key part with name "method" and the HTTP method as value
(e.g., "GET", "POST"). Chain additional extractors to build
a complete cache key.
Chain onto existing extractors using MethodExtractor::method instead
if you already have an extractor chain.
Trait Implementations§
Source§impl<S> Default for Method<NeutralExtractor<S>>
impl<S> Default for Method<NeutralExtractor<S>>
Source§impl<ReqBody, E> Extractor for Method<E>
impl<ReqBody, E> Extractor for Method<E>
Source§type Subject = <E as Extractor>::Subject
type Subject = <E as Extractor>::Subject
The type from which cache key components are extracted.
Source§fn get<'life0, 'async_trait>(
&'life0 self,
subject: <Method<E> as Extractor>::Subject,
) -> Pin<Box<dyn Future<Output = KeyParts<<Method<E> as Extractor>::Subject>> + Send + 'async_trait>>where
'life0: 'async_trait,
Method<E>: 'async_trait,
fn get<'life0, 'async_trait>(
&'life0 self,
subject: <Method<E> as Extractor>::Subject,
) -> Pin<Box<dyn Future<Output = KeyParts<<Method<E> as Extractor>::Subject>> + Send + 'async_trait>>where
'life0: 'async_trait,
Method<E>: 'async_trait,
Extract cache key components from the subject. Read more
Auto Trait Implementations§
impl<E> Freeze for Method<E>where
E: Freeze,
impl<E> RefUnwindSafe for Method<E>where
E: RefUnwindSafe,
impl<E> Send for Method<E>where
E: Send,
impl<E> Sync for Method<E>where
E: Sync,
impl<E> Unpin for Method<E>where
E: Unpin,
impl<E> UnwindSafe for Method<E>where
E: UnwindSafe,
Blanket Implementations§
Source§impl<E> BodyExtractor for Ewhere
E: Extractor,
impl<E> BodyExtractor for Ewhere
E: Extractor,
Source§fn body(self, extraction: BodyExtraction) -> Body<E>
fn body(self, extraction: BodyExtraction) -> Body<E>
Adds body extraction with the specified mode.
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