config

package
v0.0.0-...-82454b5 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig struct {
	Name          string `mapstructure:"app_name"`
	SeedData      bool   `mapstructure:"seed_data"`
	CreateAdmin   bool   `mapstructure:"create_admin"`
	AdminEmail    string `mapstructure:"admin_email"`
	AdminPassword string `mapstructure:"admin_password"`
	EnablePprof   bool   `mapstructure:"enable_pprof"`
	PprofUsername string `mapstructure:"pprof_username"`
	PprofPassword string `mapstructure:"pprof_password"`
}

AppConfig holds general application configuration

type Config

type Config struct {
	App       AppConfig
	Server    ServerConfig
	Redis     RedisConfig
	Mongo     MongoConfig
	JWT       JWTConfig
	Tracer    TracerConfig
	RateLimit RateLimitConfig
}

Config holds all application configuration

func Load

func Load() (*Config, error)

Load reads configuration from CLI flags, environment variables, and config files Priority: CLI flags > env vars > config file > defaults

type JWTConfig

type JWTConfig struct {
	PrivateKeyPath  string        `mapstructure:"jwt_private_key_path"`
	AccessTokenTTL  time.Duration `mapstructure:"jwt_access_ttl"`
	RefreshTokenTTL time.Duration `mapstructure:"jwt_refresh_ttl"`
}

JWTConfig holds JWT authentication configuration

type MongoConfig

type MongoConfig struct {
	URI      string `mapstructure:"mongo_uri"`
	Database string `mapstructure:"mongo_database"`
}

MongoConfig holds MongoDB connection configuration

type RateLimitConfig

type RateLimitConfig struct {
	Enabled bool `mapstructure:"rate_limit_enabled"`

	// Public tier - for unauthenticated/public endpoints (keyed by IP)
	Public TierRateLimitConfig `mapstructure:"public"`

	// Authenticated tier - for API users with valid JWT (keyed by user ID)
	Authenticated TierRateLimitConfig `mapstructure:"authenticated"`

	// AuthEndpoints tier - strict rate limit for login/register (keyed by IP)
	AuthEndpoints TierRateLimitConfig `mapstructure:"auth_endpoints"`
}

RateLimitConfig holds rate limiting configuration

type RedisConfig

type RedisConfig struct {
	Addr      string        `mapstructure:"redis_addr"`
	KeyPrefix string        `mapstructure:"redis_key_prefix"`
	LockTTL   time.Duration `mapstructure:"redis_lock_ttl"`
}

RedisConfig holds Redis connection configuration

type ServerConfig

type ServerConfig struct {
	BindAddr        string        `mapstructure:"bind_addr"`
	BindTLSAddr     string        `mapstructure:"bind_tls_addr"`
	ShutdownTimeout time.Duration `mapstructure:"shutdown_timeout"`
	CertFile        string        `mapstructure:"cert_file"`
	KeyFile         string        `mapstructure:"key_file"`
	EnableHSTS      bool          `mapstructure:"enable_hsts"`
}

ServerConfig holds HTTP server configuration

type TierRateLimitConfig

type TierRateLimitConfig struct {
	Enabled bool          `mapstructure:"enabled"`
	Rate    int           `mapstructure:"rate"`
	Window  time.Duration `mapstructure:"window"`
}

TierRateLimitConfig holds rate limiting configuration for a specific tier

type TracerConfig

type TracerConfig struct {
	Enabled  bool   `mapstructure:"tracer_enabled"`
	Endpoint string `mapstructure:"tracer_endpoint"`
	Insecure bool   `mapstructure:"tracer_insecure"`
}

TracerConfig holds OpenTelemetry tracer configuration

Jump to

Keyboard shortcuts

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