IWebProxy API Documentation

A comprehensive guide to the IWebProxy API.

Overview

The IWebProxy is a lightweight, asynchronous proxy that intercepts and modifies network requests. It provides a flexible and efficient way to manage data flow and improve performance.

Core Concepts

API Methods

  1. `init(options)`: Initializes the IWebProxy. Takes an optional `options` object.
  2. `intercept(request, response)`: Intercepts a request and sends a modified response.
  3. `modify(request, response, data)`: Modify a request before sending it.
  4. `send(data)`: Sends the data to the destination.
  5. `close()`: Gracefully shuts down the IWebProxy.

Example - Request Modification

Example: Modify a request to add a timestamp.

                
                function modifyRequest(request, response, data) {
                    response.headers.set('X-Custom-Timestamp', new Date().getTime());
                    return response;
                }
            
        

Example - Data Transfer

Example: Transfer data with a custom header.

                
                function sendData(data) {
                    response.headers.append('Custom-Header', data);
                    return response;
                }