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
//! Response predicates for cache storage decisions.
//!
//! These predicates evaluate HTTP responses to determine if they should be
//! stored in the cache.
//!
//! # Examples
//!
//! Cache only successful responses:
//!
//! ```
//! use hitbox_http::predicates::response::{StatusCode, StatusClass};
//!
//! # use bytes::Bytes;
//! # use http_body_util::Empty;
//! # use hitbox::Neutral;
//! # use hitbox_http::CacheableHttpResponse;
//! # type Subject = CacheableHttpResponse<Empty<Bytes>>;
//! // Match 2xx status codes
//! let predicate = StatusCode::new(http::StatusCode::OK);
//! # let _: &StatusCode<Neutral<Subject>> = &predicate;
//! // Or match the entire success class
//! let predicate = StatusCode::new_class(Neutral::new(), StatusClass::Success);
//! # let _: &StatusCode<Neutral<Subject>> = &predicate;
//! ```
//!
//! Cache responses with non-empty JSON arrays:
//!
//! ```
//! use hitbox_http::predicates::response::{Body, Operation, JqExpression, JqOperation};
//!
//! # use bytes::Bytes;
//! # use http_body_util::Empty;
//! # use hitbox::Neutral;
//! # use hitbox_http::CacheableHttpResponse;
//! # type Subject = CacheableHttpResponse<Empty<Bytes>>;
//! let predicate = Body::new(Operation::Jq {
//! filter: JqExpression::compile(".items | length > 0").unwrap(),
//! operation: JqOperation::Eq(serde_json::Value::Bool(true)),
//! });
//! # let _: &Body<Neutral<Subject>> = &predicate;
//! ```
/// HTTP status code predicates for cache storage.
pub use ;
pub use ;
pub use ;
// Re-export shared body types for convenience
pub use crate;