config

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 3, 2026 License: Apache-2.0, MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load[T Validatable]() (T, error)

Types

type Config

type Config struct {
	Repo    RepoConfig    `mapstructure:"repo" toml:"repo"`
	Gateway GatewayConfig `mapstructure:"gateway" toml:"gateway"`
}

func (Config) Validate

func (c Config) Validate() error

type GatewayConfig

type GatewayConfig struct {
	// Port is the port to run the gateway on.
	Port int `mapstructure:"port" flag:"port" toml:"port"`
	// AdvertiseURL is the external HTTPS URL at which this gateway is reachable
	// by peers (e.g. via an nginx TLS proxy). Used to construct the multiaddr
	// advertised in delegated routing responses. Must be an HTTPS URL.
	// Leave empty to disable routing responses.
	AdvertiseURL string `mapstructure:"advertise_url" flag:"advertise-url" toml:"advertise_url"`
	// BlockCacheCapacity defines the number of blocks to cache in memory. Blocks
	// are typically <1MB due to IPFS chunking, so an upper bound for how much
	// memory the cache will utilize is approximately this number multiplied by
	// 1MB. e.g. capacity for 1,000 blocks ~= 1GB of memory.
	BlockCacheCapacity int `mapstructure:"block_cache_capacity" flag:"block-cache-capacity" toml:"block_cache_capacity"`
	// LogLevel sets the logging level for the gateway server (debug, info, warn
	// or error).
	LogLevel string `mapstructure:"log_level" flag:"log-level" toml:"log_level"`
	// Subdomain configures subdomain gateway mode.
	Subdomain SubdomainConfig `mapstructure:"subdomain" toml:"subdomain"`
	// Trusted indicates whether to enable trusted gateway mode, which allows
	// deserialized responses.
	Trusted bool `mapstructure:"trusted" flag:"trusted" toml:"trusted"`
}

func (GatewayConfig) Validate

func (c GatewayConfig) Validate() error

type RepoConfig added in v0.5.0

type RepoConfig struct {
	Dir string `mapstructure:"data_dir"`
}

func (RepoConfig) DatabasePath added in v0.5.0

func (r RepoConfig) DatabasePath() string

func (RepoConfig) Validate added in v0.5.0

func (r RepoConfig) Validate() error

type SubdomainConfig

type SubdomainConfig struct {
	// Enabled indicates whether to enable subdomain gateway mode.
	Enabled bool
	// Hosts is the list of gateway hosts for subdomain mode.
	Hosts []string
}

func (SubdomainConfig) Validate

func (c SubdomainConfig) Validate() error

type Validatable

type Validatable interface {
	Validate() error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL