r402-http
HTTP transport for the x402 payment protocol, part of the
r402 workspace.
Highlights
- Server
Paygatemiddleware — axum-style layer enforcing payments with three settlement modes (sequential, concurrent, background) and pluggable hooks for KYT / API keys / observability. - Client
X402Middleware—reqwest_middlewareadapter that handles 402 challenges, signs payments, and retries the protected request. - Remote
FacilitatorClient— talks to a remote facilitator's/verify,/settle, and/supportedendpoints with a 30-second default timeout, exponential-backoff retry on429/5xx, and a 10-minute cache for/supportedshared across clones. - CORS-aware — automatically appends
Access-Control-Expose-Headersfor thePayment-RequiredandPayment-Responseheaders. - Structured 4xx parsing — facilitator clients deserialise structured
VerifyResponse::Invalid/SettleResponse::Failurebodies regardless of HTTP status code, preserving spec §9 error reasons end-to-end.
Cargo Features
| Feature | Surface |
|---|---|
client |
reqwest_middleware-based buyer middleware. |
server |
axum paygate / facilitator HTTP servers. |
facilitator |
FacilitatorClient for talking to a remote |
| facilitator. | |
telemetry |
OpenTelemetry tracing instrumentation. |
full |
All of the above. |
Documentation
- Crate docs: https://docs.rs/r402-http
- Audit reports:
../audit/. - Project README:
../README.md.
License
Dual-licensed under MIT and Apache-2.0.