Skip to main content

Module body

Module body 

Source
Expand description

Body content predicates for cache decisions.

These predicates evaluate the body content of requests or responses.

§Operations

OperationDescription
Operation::LimitCache only if body size is within limit
Operation::PlainMatch body as plain text (contains, regex, etc.)
Operation::JqEvaluate body as JSON using JQ expressions

§Caveats

Body predicates consume bytes from the stream. After evaluation:

§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.
PlainOperation
Operations for matching raw body bytes.

Traits§

BodyPredicate
Extension trait for adding body matching to a predicate chain.