config

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyDefaults

func ApplyDefaults(cfg *Config)

ApplyDefaults fills in runtime defaults for optional settings.

Types

type AccessControlConfig

type AccessControlConfig struct {
	MultiTenancy MultiTenancyConfig `mapstructure:"multi_tenancy"` // Deprecated: use Domain config
	Project      ProjectConfig      `mapstructure:"project"`       // Deprecated: managed by tenant plugin
	Domain       DomainConfig       `mapstructure:"domain"`
	ABAC         FeatureToggle      `mapstructure:"abac"`
	Share        FeatureToggle      `mapstructure:"share"`
	Quota        FeatureToggle      `mapstructure:"quota"`
	Audit        FeatureToggle      `mapstructure:"audit"`
}

type CORSConfig

type CORSConfig struct {
	Enabled          bool     `mapstructure:"enabled"`
	AllowedOrigins   []string `mapstructure:"allowed_origins"`
	AllowedMethods   []string `mapstructure:"allowed_methods"`
	AllowedHeaders   []string `mapstructure:"allowed_headers"`
	ExposedHeaders   []string `mapstructure:"exposed_headers"`
	AllowCredentials bool     `mapstructure:"allow_credentials"`
	MaxAge           int      `mapstructure:"max_age"`
}

type CacheConfig

type CacheConfig struct {
	Host     string `mapstructure:"host"`
	Port     string `mapstructure:"port"`
	Password string `mapstructure:"password"`
	DB       int    `mapstructure:"db"`
}

func (*CacheConfig) Addr

func (c *CacheConfig) Addr() string

type CaptchaConfig

type CaptchaConfig struct {
	Enabled        bool       `mapstructure:"enabled"`
	TTL            string     `mapstructure:"ttl"`
	GenerateLimit  int        `mapstructure:"generate_limit"`
	GenerateWindow string     `mapstructure:"generate_window"`
	MaxAttempts    int        `mapstructure:"max_attempts"`
	AttemptWindow  string     `mapstructure:"attempt_window"`
	Math           MathConfig `mapstructure:"math"`
}

type Config

type Config struct {
	Server        ServerConfig        `mapstructure:"server"`
	Database      DatabaseConfig      `mapstructure:"database"`
	Cache         CacheConfig         `mapstructure:"cache"`
	Log           LogConfig           `mapstructure:"log"`
	Tracing       TracingConfig       `mapstructure:"tracing"`
	Metrics       MetricsConfig       `mapstructure:"metrics"`
	Security      SecurityConfig      `mapstructure:"security"`
	AccessControl AccessControlConfig `mapstructure:"access_control"`
	Plugins       PluginsConfig       `mapstructure:"plugins"`
	Init          InitConfig          `mapstructure:"init"`
	Frontend      FrontendConfig      `mapstructure:"frontend"`
	Captcha       CaptchaConfig       `mapstructure:"captcha"`
}

func LoadConfig

func LoadConfig() *Config

type CookieConfig

type CookieConfig struct {
	Secure   bool   `mapstructure:"secure"`
	SameSite string `mapstructure:"same_site"`
	Domain   string `mapstructure:"domain"`
	Path     string `mapstructure:"path"`
}

type DatabaseConfig

type DatabaseConfig struct {
	// URL is kept for backward compatibility; if set, it takes precedence over the fields below.
	URL string `mapstructure:"url"`

	Host     string `mapstructure:"host"`
	Port     string `mapstructure:"port"`
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
	Name     string `mapstructure:"name"`
	SSLMode  string `mapstructure:"sslmode"`
	Params   string `mapstructure:"params"`

	AutoMigrate  bool `mapstructure:"auto_migrate"`
	MaxOpenConns int  `mapstructure:"max_open_conns"`
	MaxIdleConns int  `mapstructure:"max_idle_conns"`
}

func (DatabaseConfig) DSN

func (c DatabaseConfig) DSN() string

func (DatabaseConfig) Validate

func (c DatabaseConfig) Validate() error

type DomainConfig

type DomainConfig struct {
	// Mode controls domain resolution: "domain" (new) or "tenant" (legacy compat).
	Mode string `mapstructure:"mode"`
	// DefaultDomainID is the fallback domain ID when none is resolved.
	DefaultDomainID string `mapstructure:"default_domain_id"`
}

DomainConfig configures the domain kernel behavior.

type FeatureToggle

type FeatureToggle struct {
	Enabled bool `mapstructure:"enabled"`
}

type FrontendConfig

type FrontendConfig struct {
	URL string `mapstructure:"url"`
}

type InitConfig

type InitConfig struct {
	SecretKey string `mapstructure:"secret_key"`
}

type LogConfig

type LogConfig struct {
	Director       string `mapstructure:"director" json:"director" yaml:"director" toml:"director"`
	MessageKey     string `mapstructure:"message-key" json:"messageKey" yaml:"message-key" toml:"message-key"`
	LevelKey       string `mapstructure:"level-key" json:"levelKey" yaml:"level-key" toml:"level-key"`
	TimeKey        string `mapstructure:"time-key" json:"timeKey" yaml:"time-key" toml:"time-key"`
	NameKey        string `mapstructure:"name-key" json:"nameKey" yaml:"name-key" toml:"name-key"`
	CallerKey      string `mapstructure:"caller-key" json:"callerKey" yaml:"caller-key" toml:"caller-key"`
	LineEnding     string `mapstructure:"line-ending" json:"lineEnding" yaml:"line-ending" toml:"line-ending"`
	StacktraceKey  string `mapstructure:"stacktrace-key" json:"stacktraceKey" yaml:"stacktrace-key" toml:"stacktrace-key"`
	Level          string `mapstructure:"level" json:"level" yaml:"level" toml:"level"`
	EncodeLevel    string `mapstructure:"encode-level" json:"encodeLevel" yaml:"encode-level" toml:"encode-level"`
	Prefix         string `mapstructure:"prefix" json:"prefix" yaml:"prefix" toml:"prefix"`
	TimeFormat     string `mapstructure:"time-format" json:"timeFormat" yaml:"time-format" toml:"time-format"`
	Format         string `mapstructure:"format" json:"format" yaml:"format" toml:"format"`
	LogInTerminal  bool   `mapstructure:"log-in-terminal" json:"logInTerminal" yaml:"log-in-terminal" toml:"log-in-terminal"`
	MaxAge         int    `mapstructure:"max-age" json:"maxAge" yaml:"max-age" toml:"max-age"`
	MaxSize        int    `mapstructure:"max-size" json:"maxSize" yaml:"max-size" toml:"max-size"`
	MaxBackups     int    `mapstructure:"max-backups" json:"maxBackups" yaml:"max-backups" toml:"max-backups"`
	Compress       bool   `mapstructure:"compress" json:"compress" yaml:"compress" toml:"compress"`
	ShowLineNumber bool   `mapstructure:"show-line-number" json:"showLineNumber" yaml:"show-line-number" toml:"show-line-number"`
}

func (LogConfig) ToLoggingConfig

func (c LogConfig) ToLoggingConfig() logging.Config

ToLoggingConfig converts LogConfig to framework/logging.Config.

type MathConfig

type MathConfig struct {
	Width           int `mapstructure:"width"`
	Height          int `mapstructure:"height"`
	NoiseCount      int `mapstructure:"noise_count"`
	ShowLineOptions int `mapstructure:"show_line_options"`
}

type MetricsConfig

type MetricsConfig struct {
	Port string `mapstructure:"port"`
}

type MultiTenancyConfig deprecated

type MultiTenancyConfig struct {
	Enabled         bool   `mapstructure:"enabled"`
	DefaultTenantID string `mapstructure:"default_tenant_id"`
}

Deprecated: MultiTenancyConfig is superseded by DomainConfig.

type PluginsConfig

type PluginsConfig struct {
	OU FeatureToggle `mapstructure:"ou"`
}

type ProjectConfig deprecated

type ProjectConfig struct {
	Enabled          bool   `mapstructure:"enabled"`
	DefaultProjectID string `mapstructure:"default_project_id"`
	RequireProject   bool   `mapstructure:"require_project"`
}

Deprecated: ProjectConfig is managed by the tenant plugin.

type SecurityConfig

type SecurityConfig struct {
	JWTSecret       string       `mapstructure:"jwt_secret"`
	TokenExpiry     int          `mapstructure:"token_expiry"`
	RefreshExpiry   int          `mapstructure:"refresh_expiry"`
	PasswordCost    int          `mapstructure:"password_cost"`
	EnableRateLimit bool         `mapstructure:"enable_rate_limit"`
	RateLimit       int          `mapstructure:"rate_limit"`
	Cookie          CookieConfig `mapstructure:"cookie"`
}

type ServerConfig

type ServerConfig struct {
	Port int        `mapstructure:"port"`
	Mode string     `mapstructure:"mode"`
	CORS CORSConfig `mapstructure:"cors"`
}

type TracingConfig

type TracingConfig struct {
	Enabled  bool   `mapstructure:"enabled"`
	Endpoint string `mapstructure:"endpoint"`
}

Jump to

Keyboard shortcuts

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