Skip to content

05. Request Flow and Operations

gandlafbtc edited this page Sep 27, 2023 · 1 revision

This section offers a comprehensive understanding of how requests are processed within PROXNUT, detailing the steps from initiation to response delivery. It also touches on advanced operations and monitoring capabilities that enhance the system's efficiency and user experience.

5.1 Request Lifecycle

Understanding the lifecycle of a request in PROXNUT is crucial for both users and developers. Here's a step-by-step breakdown:

  1. Initiation: A user sends a request to access a protected resource. This request includes a token from their Cashu ecash wallet.

  2. Token Extraction: PROXNUT extracts the token from the request header, specifically from the X-Cashu header.

  3. Token Verification: The backend server communicates with the Cashu ecash mint to verify the token's validity and sufficiency.

  4. Resource Routing: If the token is valid, PROXNUT routes the request to the appropriate resource based on the host and route mapping configuration.

  5. Response Generation: The protected resource processes the request and generates a response.

  6. Response Delivery: PROXNUT delivers the resource's response back to the user.


5.2 Handling of Valid and Invalid Requests

Valid Requests:

  • If the token is valid and has sufficient balance, the user is granted access to the requested resource.

  • The amount corresponding to the resource's token price is deducted from the user's Cashu wallet.

Invalid Requests:

  • If the token is invalid or there's an insufficient balance, PROXNUT returns an (402) error message to the user.

  • Common error messages include "Invalid Token", "Insufficient Balance", or "Resource Not Found".

5.3 Monitoring and Configuration

PROXNUT provides tools and interfaces for monitoring:

  • Configuration: Detailed logs of all incoming requests, including timestamps, IP addresses, requested resources, and token details.

  • Analytics Dashboard: A visual interface showing metrics like total requests, successful requests, failed requests, and resource popularity.