StaticRoutingStrategy

Overview

The StaticRoutingStrategy is the simplest routing strategy that always returns a single, pre-configured gateway URL. This strategy ignores any gateways provided by the GatewaysProvider and is useful for scenarios where you want to force all requests to use a specific gateway.

How It Works

The strategy always returns the configured gateway, ignoring any provided gateway lists:

  1. Configure Gateway: Set a single gateway URL during initialization
  2. Ignore Provided Gateways: Any gateways from providers are ignored
  3. Return Static Gateway: Always return the same configured gateway
  4. Log Warnings: Warn when provided gateways are ignored

Configuration

Basic Usage

import { StaticRoutingStrategy } from '@ar.io/wayfinder-core'

const strategy = new StaticRoutingStrategy({
  gateway: 'https://arweave.net',
})

With Custom Gateway

const strategy = new StaticRoutingStrategy({
  gateway: 'https://my-custom-gateway.com',
})

// will always return the provided gateway
const selectedGateway = await strategy.selectGateway();

Parameters

ParameterTypeDefaultDescription
gatewaystringrequiredThe gateway URL to always use
loggerLoggerdefaultLoggerOptional logger instance

Was this page helpful?