handle_request

Function handle_request 

Source
pub async fn handle_request<C: ConfigProvider>(
    req: Request<Incoming>,
    forward_host: String,
    forward_port: u16,
    limiter: RateLimiter,
    config: Arc<C>,
    http_client: Client,
) -> Result<Response<Full<Bytes>>, Infallible>
Expand description

Handles an incoming HTTP request through the proxy pipeline.

This is the main entry point for request processing. It performs:

  • Client IP extraction and validation from proxy headers
  • IP blocking checks
  • URL pattern blocking (e.g., .php, .env files)
  • HTTP method blocking (e.g., PUT, DELETE)
  • Rate limiting per client IP
  • Request forwarding to the upstream service

§Arguments

  • req - The incoming HTTP request
  • forward_host - The upstream host to forward requests to
  • forward_port - The upstream port to forward requests to
  • limiter - The shared rate limiter instance
  • config - Configuration provider for all settings
  • http_client - HTTP client for forwarding requests (with connection pooling)

§Returns

Always returns Ok with either:

  • A successful proxied response from upstream
  • An error response (403, 404, 405, 429, 502, etc.)

§Security

In strict mode (when proxy allowlist is configured), requests without valid proxy headers are rejected with 403 Forbidden.