Skip to content

Class X402::Middleware

Inherits: Object

Pure Rack dispatcher for payment-gated HTTP.

The middleware has no blockchain knowledge — it matches routes, issues payment challenges by polling configured gateways, and dispatches proofs to the matching gateway for settlement.

  • @see X402::Configuration for full configuration options

@example config.ru

X402.configure { |c| c.operator_wallet_url = "https://..." }
use X402::Middleware

Public Instance Methods

call(env)

  • @param env [Hash] Rack environment
  • @return [Array(Integer, Hash, Array)] Rack response triple

initialize(app)

  • @param app [#call] next Rack app in the middleware stack
  • @return [Middleware] a new instance of Middleware