pub struct Query<E> { /* private fields */ }Expand description
Extracts query parameters as cache key parts.
Supports flexible parameter selection, value extraction, and transformation.
Array parameters (e.g., color[]=red&color[]=blue) are handled correctly.
§Key Parts Generated
For each matched parameter, generates a KeyPart with:
- Key: the parameter name
- Value: the extracted (and optionally transformed) value
§Performance
- Query string parsing allocates a
HashMapfor parameter lookup - When using
NameSelector::Starts, results are sorted alphabetically for deterministic cache keys (O(n log n) where n is matched parameters) - Regex extraction (
ValueExtractor::Regex) compiles the pattern once at construction time
Implementations§
Source§impl<S> Query<NeutralExtractor<S>>
impl<S> Query<NeutralExtractor<S>>
Sourcepub fn new(name: String) -> Self
pub fn new(name: String) -> Self
Creates a query extractor for a single parameter by exact name.
The parameter value becomes a cache key part with the parameter name
as key. For more complex extraction (prefix matching, regex, transforms),
use Query::new_with.
Chain onto existing extractors using QueryExtractor::query instead
if you already have an extractor chain.
§Examples
use hitbox_http::extractors::query::Query;
// Extract the "page" query parameter
let extractor = Query::new("page".to_string());Source§impl<E> Query<E>
impl<E> Query<E>
Sourcepub fn new_with(
inner: E,
name_selector: NameSelector,
value_extractor: ValueExtractor,
transforms: Vec<Transform>,
) -> Self
pub fn new_with( inner: E, name_selector: NameSelector, value_extractor: ValueExtractor, transforms: Vec<Transform>, ) -> Self
Creates a query parameter extractor with full configuration options.
This constructor provides complete control over query extraction:
- Select parameters by exact name or prefix pattern
- Extract full values or use regex capture groups
- Apply transformations (hash, lowercase, uppercase)
For simple exact-name extraction without transforms, use Query::new
or QueryExtractor::query instead.