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
//! Body content predicates for cache decisions.
//!
//! These predicates evaluate the body content of requests or responses.
//!
//! # Operations
//!
//! | Operation | Description |
//! |-----------|-------------|
//! | [`Operation::Limit`] | Cache only if body size is within limit |
//! | [`Operation::Plain`] | Match body as plain text (contains, regex, etc.) |
//! | [`Operation::Jq`] | Evaluate body as JSON using JQ expressions |
//!
//! # Caveats
//!
//! Body predicates consume bytes from the stream. After evaluation:
//! - The body transitions to [`BufferedBody::Partial`] or [`BufferedBody::Complete`]
//! - Subsequent predicates receive the modified body state
//! - Order your predicates to minimize body consumption
//!
//! # Examples
//!
//! Only cache responses with non-empty JSON arrays:
//!
//! ```
//! use hitbox_http::predicates::body::{Operation, JqExpression, JqOperation};
//!
//! let op = Operation::Jq {
//! filter: JqExpression::compile(".items | length > 0").unwrap(),
//! operation: JqOperation::Eq(serde_json::Value::Bool(true)),
//! };
//! ```
//!
//! [`BufferedBody::Partial`]: crate::BufferedBody::Partial
//! [`BufferedBody::Complete`]: crate::BufferedBody::Complete
pub use ;
pub use Operation;
pub use PlainOperation;
pub use ;