tower_request_guard/lib.rs
1//! Request validation middleware for [`tower`] services.
2//!
3//! `tower-request-guard` validates incoming requests before they reach
4//! the handler: body size limits, timeouts, content-type enforcement,
5//! required headers, and JSON depth protection.
6
7/// Body size checks and bodyless-method detection.
8pub mod body;
9/// Content-Type media type matching.
10pub mod content_type;
11/// Guard configuration and builder.
12pub mod guard;
13/// Required header validation.
14pub mod headers;
15/// Tower [`Layer`](tower_layer::Layer) implementation.
16pub mod layer;
17/// HTTP error response generation for violations.
18pub mod response;
19/// Per-route override configuration via [`route_guard`].
20pub mod route;
21/// Tower [`Service`](tower_service::Service) that enforces request validation.
22pub mod service;
23/// Violation types, actions, and handling policies.
24pub mod violation;
25
26/// JSON depth validation (requires `json` feature).
27#[cfg(feature = "json")]
28pub mod json;
29
30/// Buffered body variant for JSON depth protection (requires `json` feature).
31#[cfg(feature = "json")]
32pub mod buffered;
33
34// Re-exports
35pub use guard::RequestGuard;
36pub use layer::RequestGuardLayer;
37pub use route::route_guard;
38pub use service::RequestGuardService;
39pub use violation::{OnViolation, Violation, ViolationAction};
40
41#[cfg(feature = "json")]
42pub use buffered::{BufferedRequestGuardLayer, BufferedRequestGuardService};