Skip to main content

Module server

Module server 

Source
Available on crate feature server only.
Expand description

Axum middleware for enforcing x402 payments on protected routes (V2-only).

This middleware validates incoming payment headers using a configured x402 facilitator, and settles valid payments either before or after request execution (configurable).

Returns a 402 Payment Required response if the request lacks a valid payment.

See X402Middleware for full configuration options. For low-level interaction with the facilitator, see facilitator::FacilitatorClient.

§Settlement Timing

By default, settlement occurs after the request is processed. You can change this behavior:

§Configuration Notes

Re-exports§

pub use layer::X402LayerBuilder;
pub use layer::X402Middleware;
pub use pricing::DynamicPriceTags;
pub use pricing::PriceTagSource;
pub use pricing::StaticPriceTags;

Modules§

facilitator
A r402::facilitator::Facilitator implementation that interacts with a remote x402 Facilitator over HTTP.
layer
Axum middleware for enforcing x402 payments on protected routes.
paygate
Core payment gate logic for enforcing x402 payments (V2-only).
pricing
Price tag sources for the x402 payment gate.

Enums§

PaygateError
Paygate error type that wraps verification and settlement errors.
VerificationError
Common verification errors shared between protocol versions.