1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
//! Predicates for determining HTTP request and response cacheability.
//!
//! Predicates evaluate HTTP messages and return [`Cacheable`] or [`NonCacheable`].
//! They can be combined using logical operators from the [`conditions`] module.
//!
//! # Request vs Response Predicates
//!
//! - **Request predicates** decide whether to attempt a cache lookup
//! - **Response predicates** decide whether to store a response in cache
//!
//! # Available Predicates
//!
//! ## Request Predicates ([`request`] module)
//!
//! | Predicate | Description |
//! |-----------|-------------|
//! | [`request::Method`] | Match by HTTP method |
//! | [`request::Path`] | Match by URL path pattern |
//! | [`request::Header`] | Match by request header |
//! | [`request::Query`] | Match by query parameter |
//! | [`request::Body`] | Match by request body content |
//!
//! ## Response Predicates ([`response`] module)
//!
//! | Predicate | Description |
//! |-----------|-------------|
//! | [`response::StatusCode`] | Match by status code or class |
//! | [`response::Header`] | Match by response header |
//! | [`response::Body`] | Match by response body content |
//!
//! # Combining Predicates
//!
//! Use [`PredicateExt`] to combine predicates:
//!
//! ```
//! use hitbox::predicate::PredicateExt;
//! use hitbox_http::predicates::request::Method;
//! use hitbox_http::predicates::header::{Header, Operation};
//!
//! # use bytes::Bytes;
//! # use http_body_util::Empty;
//! # use hitbox::Neutral;
//! # use hitbox::predicate::And;
//! # use hitbox_http::CacheableHttpRequest;
//! # type Subject = CacheableHttpRequest<Empty<Bytes>>;
//! // Cache GET requests without Cache-Control: no-cache
//! let predicate = Method::new(http::Method::GET).unwrap();
//! # let _: &Method<Neutral<Subject>> = &predicate;
//! let predicate = predicate.and(
//! Header::new(Operation::Contains(
//! http::header::CACHE_CONTROL,
//! "no-cache".to_string(),
//! )).not()
//! );
//! ```
//!
//! [`Cacheable`]: hitbox::predicate::PredicateResult::Cacheable
//! [`NonCacheable`]: hitbox::predicate::PredicateResult::NonCacheable
//! [`PredicateExt`]: conditions::PredicateExt
use Neutral;
use crate::;
/// A neutral predicate for HTTP requests that always returns `Cacheable`.
///
/// Use this when you want to cache all requests regardless of their properties,
/// or as a starting point for predicate chains with `PredicateExt`.
pub type NeutralRequestPredicate<ReqBody> = ;
/// A neutral predicate for HTTP responses that always returns `Cacheable`.
///
/// Use this when you want to cache all responses regardless of their properties,
/// or as a starting point for predicate chains with `PredicateExt`.
pub type NeutralResponsePredicate<ResBody> = ;