Expand description
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::PartialorBufferedBody::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)),
};Structs§
- Body
- A predicate that matches HTTP bodies against an
Operation. - JqExpression
- A compiled jq expression for querying JSON bodies.
Enums§
- JqOperation
- Operations for matching jq query results.
- Operation
- Matching operations for HTTP body content.
- Plain
Operation - Operations for matching raw body bytes.
Traits§
- Body
Predicate - Extension trait for adding body matching to a predicate chain.