r402_http/server/mod.rs
1//! Axum middleware for enforcing [x402](https://www.x402.org) payments on protected routes (V2-only).
2//!
3//! This middleware validates incoming payment headers using a configured x402 facilitator,
4//! verifies the payment, executes the request, and settles valid payments after successful
5//! execution. If the handler returns an error (4xx/5xx), settlement is skipped.
6//!
7//! Returns a `402 Payment Required` response if the request lacks a valid payment.
8//!
9//! See [`X402Middleware`] for full configuration options.
10//! For low-level interaction with the facilitator, see [`facilitator::FacilitatorClient`].
11//!
12//! ## Settlement Modes
13//!
14//! - **[`SettlementMode::Sequential`]** (default): verify → execute → settle.
15//! - **[`SettlementMode::Concurrent`]**: verify → (settle ∥ execute) → await settle.
16
17pub mod facilitator;
18pub mod layer;
19pub mod paygate;
20pub mod pricing;
21
22pub use layer::{SettlementMode, X402LayerBuilder, X402Middleware};
23pub use paygate::{
24 Paygate, PaygateBuilder, PaygateError, ResourceTemplate, VerificationError, VerifiedPayment,
25 settlement_to_header,
26};
27pub use pricing::{DynamicPriceTags, PriceTagSource, StaticPriceTags};