config

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2026 License: MIT Imports: 1 Imported by: 0

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