Skip to main content
Version: 1.0.x

Direct Mode

Direct Mode allows you to route your API traffic through Lunar.dev Gateway without installing an Interceptor. This mode modifies your requests by adding specific headers and altering the request URL.

Direct Mode Setup

  1. Prepare Your Request

Start with the request you wish to make, for example, https://catfact.ninja/fact.

  1. Add Necessary Headers
note

Any header starting with x-lunar will be automatically removed before the request is forwarded to third-party providers. Ensure these headers are included for internal routing and management purposes only.

Incorporate the following headers into your request:

  • x-lunar-scheme: Reflects the original scheme of your request. For HTTPS requests, use https.
  • x-lunar-host: The host you intend to communicate with, such as catfact.ninja for the given example.
  • x-lunar-consumer-tag (optional): Use this header to indicate the originating application or service, helpful for traffic segmentation.

Your request now should carry these additional headers.

  1. Modify the Request URL

Alter the URL of your request to route through the Lunar Proxy. Use the format: http://lunar_proxy_address:lunar_proxy_port/original/request/path

Replace lunar_proxy_address with the DNS or IP of the Lunar Proxy, and lunar_proxy_port with the listening port number.

For instance, with the Lunar Proxy at localhost and port 8000, the modified URL for our example would be:

  curl http://localhost:8000/fact -H "x-lunar-host: catfact.ninja" -H "x-lunar-scheme: https" -H "x-lunar-consumer-tag: example-app"

Or, with wget:

  wget -qO - --header="x-lunar-host: catfact.ninja" --header="x-lunar-scheme: https" --header="x-lunar-consumer-tag: example-app" http://localhost:8000/fact
  1. Execute Your Request

With the headers added and the URL adjusted, send your request. Direct Mode will ensure it's efficiently directed to the intended destination while preserving the original scheme and host.

CTRL + M