Expand description
Cache key extractors for HTTP requests.
Extractors generate cache key parts from HTTP request components. They
implement the Extractor trait and can be chained using the builder pattern.
§Available Extractors
| Extractor | Description |
|---|---|
Method | Extract HTTP method (GET, POST, etc.) |
Path | Extract path parameters using patterns like /users/{id} |
header::Header | Extract header values |
query::Query | Extract query parameters |
body::Body | Extract from body (hash, JQ, regex) |
Version | Extract HTTP version |
§Builder Pattern
Start with Method::new() and chain other extractors:
use hitbox_http::extractors::{Method, path::PathExtractor, query::QueryExtractor};
let extractor = Method::new()
.path("/users/{user_id}/posts/{post_id}")
.query("page".to_string())
.query("limit".to_string());§Cache Key Structure
Each extractor adds KeyParts to the cache key. A KeyPart has:
- A name (e.g., “user_id”, “page”, “method”)
- An optional value (e.g., “42”, “1”, “GET”)
The final cache key is computed from all collected parts.
§Transforms
Header and query extractors support value transformations via transform::Transform:
Hash: SHA256 hash (truncated to 16 hex chars)Lowercase: Convert to lowercaseUppercase: Convert to uppercase
Re-exports§
Modules§
- body
- Body content extraction for cache keys.
- header
- Header extraction for cache keys.
- method
- HTTP method extraction for cache keys.
- path
- Path parameter extraction for cache keys.
- query
- Query parameter extraction for cache keys.
- transform
- Shared value transformations for extractors.
- version
- HTTP version extraction for cache keys.
Structs§
- Neutral
Extractor - Base extractor that produces an empty cache key.