Skip to main content

Module error

Module error 

Source
Expand description

HTTP response and error-construction helpers shared across the request handler.

Kept separate from [crate::handler] so error-shape concerns (what does a 400 vs 403 vs 502 body look like) are reviewable independently of routing/business logic, and so the body-reading size-limit logic — which has a non-obvious “did the connection error or did the body exceed the limit” distinction — has room to be documented and tested on its own.

Enums§

BodyReadError
Why reading the request body failed.

Functions§

classify_upstream_error
Classify a guardrail_core::GuardrailError::Upstream into a coarse error class for the guardrail_upstream_errors_total metric label.
error_body_response
Wrap an arbitrary JSON value as a full HTTP response with the given status.
error_response
Build a standard error response body and wrap it as a full HTTP response.
internal_error_response
A generic 500 response for failures that have no more specific status.
read_limited_body
Read an incoming request body, enforcing max_size as a byte ceiling.