Skip to main content

Module request

Module request 

Source
Expand description

Request predicates for cache eligibility.

These predicates evaluate incoming HTTP requests to determine if a cache lookup should be attempted.

§Examples

Cache only GET and HEAD requests:

use hitbox_http::predicates::request::Method;

// Single method
let predicate = Method::new(http::Method::GET).unwrap();

// Multiple methods
let predicate = Method::new_in(
    Neutral::new(),
    vec![http::Method::GET, http::Method::HEAD],
);

Skip cache for requests with Cache-Control: no-cache:

use hitbox::predicate::PredicateExt;
use hitbox_http::predicates::header::{Header, Operation};

let predicate = Header::new(Operation::Contains(
    http::header::CACHE_CONTROL,
    "no-cache".to_string(),
));
let predicate = predicate.not();

Re-exports§

pub use body::Body;
pub use body::BodyPredicate;
pub use header::Header;
pub use header::HeaderPredicate;
pub use method::Method;
pub use method::MethodPredicate;
pub use path::Path;
pub use path::PathPredicate;
pub use query::Query;
pub use query::QueryPredicate;

Modules§

body
Request body matching predicates.
header
Request header matching predicates.
method
HTTP method predicates for cache eligibility.
path
Path pattern matching predicate.
query
Query parameter matching predicate.