Skip to main content

Module extractors

Module extractors 

Source
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

ExtractorDescription
MethodExtract HTTP method (GET, POST, etc.)
PathExtract path parameters using patterns like /users/{id}
header::HeaderExtract header values
query::QueryExtract query parameters
body::BodyExtract from body (hash, JQ, regex)
VersionExtract 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 lowercase
  • Uppercase: Convert to uppercase

Re-exports§

pub use method::Method;
pub use path::Path;
pub use version::Version;

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§

NeutralExtractor
Base extractor that produces an empty cache key.