config

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 1 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// DefaultCountryCode is used whenever a country cannot otherwise be
	// resolved (no account-country resolver registered / no match, IP
	// lookup inconclusive or disabled, or the resolved country isn't
	// active). Must be a code present in the countries table. Defaults to
	// "ZZ" ("Global", USD, seeded by migration 000002) rather than any
	// specific country — a generic framework module has no basis for
	// assuming a host app's home country, and "Global" is honest about
	// being a fallback rather than silently impersonating one country's
	// data. Host apps with a strong home-market bias (e.g. before their
	// own GeoIP is configured) can override this back to their own
	// country code.
	DefaultCountryCode string `yaml:"defaultCountryCode" validate:"required,len=2"`

	GeoIP GeoIPConfig `yaml:"geoIP"`
}

Config is the localization module's configuration.

func Default

func Default() *Config

func (*Config) Key

func (c *Config) Key() string

func (*Config) Validate

func (c *Config) Validate() error

type GeoIPConfig

type GeoIPConfig struct {
	Provider GeoIPProvider `yaml:"provider"`

	// MaxMindDBPath is required when Provider == "maxmind" — a filesystem
	// path to a GeoLite2-Country (or GeoIP2-Country) .mmdb file.
	MaxMindDBPath string `yaml:"maxMindDBPath"`

	// HeaderName is the header read when Provider == "cloudflare-header".
	// Defaults to "CF-IPCountry" if empty.
	HeaderName string `yaml:"headerName"`
}

GeoIPConfig configures IP-based country detection.

type GeoIPProvider

type GeoIPProvider string

GeoIPProvider selects how DetectedCountry (Section A2 — display/discovery only, never authoritative for billing) is resolved from a client IP.

const (
	// GeoIPProviderNone disables IP-based country detection entirely;
	// only AccountCountry resolution (if the host app registered a
	// resolver) is available.
	GeoIPProviderNone GeoIPProvider = "none"
	// GeoIPProviderMaxMind reads a self-hosted MaxMind GeoLite2-Country
	// (or commercial GeoIP2-Country) database file.
	GeoIPProviderMaxMind GeoIPProvider = "maxmind"
	// GeoIPProviderCloudflareHeader trusts a CF-IPCountry (or configurable
	// header name) header injected by a Cloudflare-fronted deployment.
	GeoIPProviderCloudflareHeader GeoIPProvider = "cloudflare-header"
)

Jump to

Keyboard shortcuts

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