config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnv

func GetEnv(key, defaultValue string) string

GetEnv gets an environment variable with default value

func GetEnvBool

func GetEnvBool(key string, defaultValue bool) bool

GetEnvBool gets an environment variable as boolean with default value

func GetEnvDuration

func GetEnvDuration(key string, defaultValue time.Duration) time.Duration

GetEnvDuration gets an environment variable as duration with default value

func GetEnvInt

func GetEnvInt(key string, defaultValue int) int

GetEnvInt gets an environment variable as integer with default value

Types

type AppConfig

type AppConfig struct {
	// Basic app settings
	Name        string `env:"APP_NAME" default:"Mithril App" required:"true" min:"1" max:"100"`
	Version     string `env:"APP_VERSION" default:"1.0.0" required:"true"`
	Environment string `env:"APP_ENV" default:"development" required:"true"`
	Debug       bool   `env:"APP_DEBUG" default:"false"`

	// Server settings
	Host string `env:"APP_HOST" default:"0.0.0.0" required:"true"`
	Port string `env:"APP_PORT" default:"3000" required:"true"`

	// Timezone
	Timezone string `env:"APP_TIMEZONE" default:"UTC" required:"true"`

	// Security
	SecretKey string `env:"APP_SECRET_KEY" required:"true" min:"32"`

	// CORS settings
	CORSAllowedOrigins []string `env:"CORS_ALLOWED_ORIGINS" default:"*"`
	CORSAllowedMethods []string `env:"CORS_ALLOWED_METHODS" default:"GET,POST,PUT,DELETE,OPTIONS"`
	CORSAllowedHeaders []string `env:"CORS_ALLOWED_HEADERS" default:"Content-Type,Authorization,X-Requested-With"`

	// Rate limiting
	RateLimitEnabled bool          `env:"RATE_LIMIT_ENABLED" default:"true"`
	RateLimitRPS     int           `env:"RATE_LIMIT_RPS" default:"100"`
	RateLimitBurst   int           `env:"RATE_LIMIT_BURST" default:"200"`
	RateLimitWindow  time.Duration `env:"RATE_LIMIT_WINDOW" default:"1m"`

	// File upload settings
	MaxUploadSize int64 `env:"MAX_UPLOAD_SIZE" default:"10485760"` // 10MB

	// Session settings
	SessionName     string        `env:"SESSION_NAME" default:"mithril_session"`
	SessionSecret   string        `env:"SESSION_SECRET" required:"true" min:"32"`
	SessionLifetime time.Duration `env:"SESSION_LIFETIME" default:"24h"`

	// Logging
	LogLevel  string `env:"LOG_LEVEL" default:"info"`
	LogFormat string `env:"LOG_FORMAT" default:"json"`

	// Health check settings
	HealthCheckPath string `env:"HEALTH_CHECK_PATH" default:"/health"`
	ReadyCheckPath  string `env:"READY_CHECK_PATH" default:"/ready"`

	// Metrics
	MetricsEnabled bool   `env:"METRICS_ENABLED" default:"true"`
	MetricsPath    string `env:"METRICS_PATH" default:"/metrics"`

	// Monitoring
	MonitoringEnabled bool   `env:"MONITORING_ENABLED" default:"true"`
	MonitoringPath    string `env:"MONITORING_PATH" default:"/monitor"`
}

AppConfig holds application configuration

func NewAppConfig

func NewAppConfig() *AppConfig

NewAppConfig creates a new AppConfig from environment variables

func (*AppConfig) GetAddress

func (c *AppConfig) GetAddress() string

GetAddress returns the full server address

func (*AppConfig) GetCORSAllowedHeaders

func (c *AppConfig) GetCORSAllowedHeaders() []string

GetCORSAllowedHeaders returns CORS allowed headers as a slice

func (*AppConfig) GetCORSAllowedMethods

func (c *AppConfig) GetCORSAllowedMethods() []string

GetCORSAllowedMethods returns CORS allowed methods as a slice

func (*AppConfig) GetCORSAllowedOrigins

func (c *AppConfig) GetCORSAllowedOrigins() []string

GetCORSAllowedOrigins returns CORS allowed origins as a slice

func (*AppConfig) GetLogFormat

func (c *AppConfig) GetLogFormat() string

GetLogFormat returns the log format

func (*AppConfig) GetLogLevel

func (c *AppConfig) GetLogLevel() string

GetLogLevel returns the log level

func (*AppConfig) GetMaxUploadSizeMB

func (c *AppConfig) GetMaxUploadSizeMB() int64

GetMaxUploadSizeMB returns max upload size in MB

func (*AppConfig) IsDevelopment

func (c *AppConfig) IsDevelopment() bool

IsDevelopment returns true if the app is in development mode

func (*AppConfig) IsProduction

func (c *AppConfig) IsProduction() bool

IsProduction returns true if the app is in production mode

func (*AppConfig) IsStaging

func (c *AppConfig) IsStaging() bool

IsStaging returns true if the app is in staging mode

func (*AppConfig) IsTesting

func (c *AppConfig) IsTesting() bool

IsTesting returns true if the app is in testing mode

type CORSConfig

type CORSConfig struct {
	// Basic CORS settings
	Enabled          bool     `env:"CORS_ENABLED" default:"true"`
	AllowedOrigins   []string `env:"CORS_ALLOWED_ORIGINS" default:"*"`
	AllowedMethods   []string `env:"CORS_ALLOWED_METHODS" default:"GET,POST,PUT,DELETE,OPTIONS"`
	AllowedHeaders   []string `env:"CORS_ALLOWED_HEADERS" default:"Content-Type,Authorization,X-Requested-With"`
	ExposedHeaders   []string `env:"CORS_EXPOSED_HEADERS" default:""`
	AllowCredentials bool     `env:"CORS_ALLOW_CREDENTIALS" default:"true"`
	MaxAge           int      `env:"CORS_MAX_AGE" default:"86400"` // 24 hours

	// Advanced settings
	AllowWildcard          bool `env:"CORS_ALLOW_WILDCARD" default:"true"`
	AllowBrowserExtensions bool `env:"CORS_ALLOW_BROWSER_EXTENSIONS" default:"false"`
	AllowWebSockets        bool `env:"CORS_ALLOW_WEB_SOCKETS" default:"true"`
	AllowFiles             bool `env:"CORS_ALLOW_FILES" default:"false"`

	// Security settings
	AllowPrivateNetwork bool   `env:"CORS_ALLOW_PRIVATE_NETWORK" default:"false"`
	VaryHeader          string `env:"CORS_VARY_HEADER" default:"Origin"`

	// Debug settings
	Debug    bool   `env:"CORS_DEBUG" default:"false"`
	LogLevel string `env:"CORS_LOG_LEVEL" default:"info"`

	// Custom settings
	CustomHeaders map[string]string `env:"CORS_CUSTOM_HEADERS" default:""`
	CustomMethods []string          `env:"CORS_CUSTOM_METHODS" default:""`
	CustomOrigins []string          `env:"CORS_CUSTOM_ORIGINS" default:""`

	// Rate limiting
	RateLimitEnabled bool `env:"CORS_RATE_LIMIT_ENABLED" default:"false"`
	RateLimitRPS     int  `env:"CORS_RATE_LIMIT_RPS" default:"100"`
	RateLimitBurst   int  `env:"CORS_RATE_LIMIT_BURST" default:"200"`

	// Health check
	HealthCheckEnabled bool   `env:"CORS_HEALTH_CHECK_ENABLED" default:"true"`
	HealthCheckPath    string `env:"CORS_HEALTH_CHECK_PATH" default:"/health"`
}

CORSConfig holds CORS configuration

func (*CORSConfig) GetAllowedHeaders

func (c *CORSConfig) GetAllowedHeaders() []string

GetAllowedHeaders returns the allowed headers

func (*CORSConfig) GetAllowedMethods

func (c *CORSConfig) GetAllowedMethods() []string

GetAllowedMethods returns the allowed methods

func (*CORSConfig) GetAllowedOrigins

func (c *CORSConfig) GetAllowedOrigins() []string

GetAllowedOrigins returns the allowed origins

func (*CORSConfig) GetCustomHeaders

func (c *CORSConfig) GetCustomHeaders() map[string]string

GetCustomHeaders returns the custom headers

func (*CORSConfig) GetCustomMethods

func (c *CORSConfig) GetCustomMethods() []string

GetCustomMethods returns the custom methods

func (*CORSConfig) GetCustomOrigins

func (c *CORSConfig) GetCustomOrigins() []string

GetCustomOrigins returns the custom origins

func (*CORSConfig) GetExposedHeaders

func (c *CORSConfig) GetExposedHeaders() []string

GetExposedHeaders returns the exposed headers

func (*CORSConfig) GetHealthCheckPath

func (c *CORSConfig) GetHealthCheckPath() string

GetHealthCheckPath returns the health check path

func (*CORSConfig) GetLogLevel

func (c *CORSConfig) GetLogLevel() string

GetLogLevel returns the log level

func (*CORSConfig) GetMaxAge

func (c *CORSConfig) GetMaxAge() int

GetMaxAge returns the max age in seconds

func (*CORSConfig) GetRateLimitBurst

func (c *CORSConfig) GetRateLimitBurst() int

GetRateLimitBurst returns the rate limit burst

func (*CORSConfig) GetRateLimitRPS

func (c *CORSConfig) GetRateLimitRPS() int

GetRateLimitRPS returns the rate limit RPS

func (*CORSConfig) GetVaryHeader

func (c *CORSConfig) GetVaryHeader() string

GetVaryHeader returns the vary header

func (*CORSConfig) IsAllowBrowserExtensions

func (c *CORSConfig) IsAllowBrowserExtensions() bool

IsAllowBrowserExtensions returns whether browser extensions are allowed

func (*CORSConfig) IsAllowCredentials

func (c *CORSConfig) IsAllowCredentials() bool

IsAllowCredentials returns whether credentials are allowed

func (*CORSConfig) IsAllowFiles

func (c *CORSConfig) IsAllowFiles() bool

IsAllowFiles returns whether files are allowed

func (*CORSConfig) IsAllowPrivateNetwork

func (c *CORSConfig) IsAllowPrivateNetwork() bool

IsAllowPrivateNetwork returns whether private network is allowed

func (*CORSConfig) IsAllowWebSockets

func (c *CORSConfig) IsAllowWebSockets() bool

IsAllowWebSockets returns whether WebSockets are allowed

func (*CORSConfig) IsAllowWildcard

func (c *CORSConfig) IsAllowWildcard() bool

IsAllowWildcard returns whether wildcard is allowed

func (*CORSConfig) IsDebug

func (c *CORSConfig) IsDebug() bool

IsDebug returns whether debug mode is enabled

func (*CORSConfig) IsEnabled

func (c *CORSConfig) IsEnabled() bool

IsEnabled returns whether CORS is enabled

func (*CORSConfig) IsHeaderAllowed

func (c *CORSConfig) IsHeaderAllowed(header string) bool

IsHeaderAllowed checks if a header is allowed

func (*CORSConfig) IsHealthCheckEnabled

func (c *CORSConfig) IsHealthCheckEnabled() bool

IsHealthCheckEnabled returns whether health check is enabled

func (*CORSConfig) IsMethodAllowed

func (c *CORSConfig) IsMethodAllowed(method string) bool

IsMethodAllowed checks if a method is allowed

func (*CORSConfig) IsOriginAllowed

func (c *CORSConfig) IsOriginAllowed(origin string) bool

IsOriginAllowed checks if an origin is allowed

func (*CORSConfig) IsRateLimitEnabled

func (c *CORSConfig) IsRateLimitEnabled() bool

IsRateLimitEnabled returns whether rate limiting is enabled

type CacheConfig

type CacheConfig struct {
	Driver   string
	Host     string
	Port     int
	Password string
	Database int
	Prefix   string
	TTL      time.Duration
}

CacheConfig holds cache configuration

func NewCacheConfig

func NewCacheConfig() *CacheConfig

NewCacheConfig creates a new cache configuration from environment variables

type ConfigManager

type ConfigManager struct {
	// contains filtered or unexported fields
}

ConfigManager handles configuration loading and management

func NewConfigManager

func NewConfigManager(envFile string) *ConfigManager

NewConfigManager creates a new configuration manager

func (*ConfigManager) Get

func (cm *ConfigManager) Get(name string) (interface{}, bool)

Get retrieves a configuration by name

func (*ConfigManager) GetTyped

func (cm *ConfigManager) GetTyped(name string, target interface{}) error

GetTyped retrieves a typed configuration

func (*ConfigManager) Load

func (cm *ConfigManager) Load() error

Load loads configuration from environment and .env file

func (*ConfigManager) Register

func (cm *ConfigManager) Register(name string, config interface{}) error

Register registers a configuration struct

type DatabaseConfig

type DatabaseConfig struct {
	// Primary database connection
	Driver   string `env:"DB_DRIVER" default:"postgres" required:"true"`
	Host     string `env:"DB_HOST" default:"localhost" required:"true"`
	Port     int    `env:"DB_PORT" default:"5432" required:"true"`
	Username string `env:"DB_USERNAME" default:"mithril" required:"true"`
	Password string `env:"DB_PASSWORD" required:"true"`
	Database string `env:"DB_NAME" default:"mithril" required:"true"`

	// Connection pool settings
	MaxOpenConns    int           `env:"DB_MAX_OPEN_CONNS" default:"25"`
	MaxIdleConns    int           `env:"DB_MAX_IDLE_CONNS" default:"5"`
	ConnMaxLifetime time.Duration `env:"DB_CONN_MAX_LIFETIME" default:"5m"`
	ConnMaxIdleTime time.Duration `env:"DB_CONN_MAX_IDLE_TIME" default:"1m"`

	// SSL settings
	SSLMode string `env:"DB_SSL_MODE" default:"disable"`

	// Migration settings
	MigrationPath string `env:"DB_MIGRATION_PATH" default:"./database/migrations"`

	// Seeder settings
	SeederPath string `env:"DB_SEEDER_PATH" default:"./database/seeders"`

	// Backup settings
	BackupPath string `env:"DB_BACKUP_PATH" default:"./database/backups"`

	// Additional database connections
	RedisHost     string `env:"REDIS_HOST" default:"localhost"`
	RedisPort     int    `env:"REDIS_PORT" default:"6379"`
	RedisPassword string `env:"REDIS_PASSWORD" default:""`
	RedisDB       int    `env:"REDIS_DB" default:"0"`

	// MongoDB settings (if used)
	MongoURI      string `env:"MONGO_URI" default:""`
	MongoDatabase string `env:"MONGO_DATABASE" default:"mithril"`

	// MySQL settings (if used)
	MySQLCharset   string `env:"MYSQL_CHARSET" default:"utf8mb4"`
	MySQLParseTime bool   `env:"MYSQL_PARSE_TIME" default:"true"`
	MySQLLoc       string `env:"MYSQL_LOC" default:"Local"`

	// SQLite settings (if used)
	SQLitePath string `env:"SQLITE_PATH" default:"./database/sqlite.db"`
}

DatabaseConfig holds database configuration

func NewDatabaseConfig

func NewDatabaseConfig() *DatabaseConfig

NewDatabaseConfig creates a new DatabaseConfig from environment variables

func (*DatabaseConfig) GetBackupPath

func (c *DatabaseConfig) GetBackupPath() string

GetBackupPath returns the backup path

func (*DatabaseConfig) GetDSN

func (c *DatabaseConfig) GetDSN() string

GetDSN returns the database connection string

func (*DatabaseConfig) GetMigrationPath

func (c *DatabaseConfig) GetMigrationPath() string

GetMigrationPath returns the migration path

func (*DatabaseConfig) GetRedisAddr

func (c *DatabaseConfig) GetRedisAddr() string

GetRedisAddr returns Redis address

func (*DatabaseConfig) GetRedisDB

func (c *DatabaseConfig) GetRedisDB() int

GetRedisDB returns Redis database number

func (*DatabaseConfig) GetRedisPassword

func (c *DatabaseConfig) GetRedisPassword() string

GetRedisPassword returns Redis password

func (*DatabaseConfig) GetSeederPath

func (c *DatabaseConfig) GetSeederPath() string

GetSeederPath returns the seeder path

func (*DatabaseConfig) IsMongoDB

func (c *DatabaseConfig) IsMongoDB() bool

IsMongoDB returns true if using MongoDB

func (*DatabaseConfig) IsMySQL

func (c *DatabaseConfig) IsMySQL() bool

IsMySQL returns true if using MySQL

func (*DatabaseConfig) IsPostgres

func (c *DatabaseConfig) IsPostgres() bool

IsPostgres returns true if using PostgreSQL

func (*DatabaseConfig) IsSQLite

func (c *DatabaseConfig) IsSQLite() bool

IsSQLite returns true if using SQLite

type JWTConfig

type JWTConfig struct {
	// Secret key for signing tokens
	Secret string `env:"JWT_SECRET" required:"true" min:"32"`

	// Token expiration times
	AccessTokenExpiry  time.Duration `env:"JWT_ACCESS_TOKEN_EXPIRY" default:"15m"`
	RefreshTokenExpiry time.Duration `env:"JWT_REFRESH_TOKEN_EXPIRY" default:"7d"`

	// Algorithm for signing tokens
	Algorithm string `env:"JWT_ALGORITHM" default:"HS256"`

	// Issuer and audience
	Issuer   string `env:"JWT_ISSUER" default:"mithril"`
	Audience string `env:"JWT_AUDIENCE" default:"mithril-users"`

	// Token refresh settings
	RefreshThreshold time.Duration `env:"JWT_REFRESH_THRESHOLD" default:"5m"`

	// Cookie settings for refresh tokens
	CookieName     string        `env:"JWT_COOKIE_NAME" default:"refresh_token"`
	CookiePath     string        `env:"JWT_COOKIE_PATH" default:"/"`
	CookieDomain   string        `env:"JWT_COOKIE_DOMAIN" default:""`
	CookieSecure   bool          `env:"JWT_COOKIE_SECURE" default:"false"`
	CookieHTTPOnly bool          `env:"JWT_COOKIE_HTTP_ONLY" default:"true"`
	CookieSameSite string        `env:"JWT_COOKIE_SAME_SITE" default:"Lax"`
	CookieMaxAge   time.Duration `env:"JWT_COOKIE_MAX_AGE" default:"604800"` // 7 days

	// Blacklist settings
	BlacklistEnabled bool          `env:"JWT_BLACKLIST_ENABLED" default:"true"`
	BlacklistTTL     time.Duration `env:"JWT_BLACKLIST_TTL" default:"24h"`

	// Rate limiting for token generation
	TokenRateLimitEnabled bool          `env:"JWT_RATE_LIMIT_ENABLED" default:"true"`
	TokenRateLimitRPS     int           `env:"JWT_RATE_LIMIT_RPS" default:"10"`
	TokenRateLimitBurst   int           `env:"JWT_RATE_LIMIT_BURST" default:"20"`
	TokenRateLimitWindow  time.Duration `env:"JWT_RATE_LIMIT_WINDOW" default:"1m"`

	// 2FA settings
	TwoFactorEnabled bool          `env:"JWT_2FA_ENABLED" default:"true"`
	TwoFactorExpiry  time.Duration `env:"JWT_2FA_EXPIRY" default:"5m"`

	// Password reset settings
	PasswordResetExpiry time.Duration `env:"JWT_PASSWORD_RESET_EXPIRY" default:"1h"`

	// Email verification settings
	EmailVerificationExpiry time.Duration `env:"JWT_EMAIL_VERIFICATION_EXPIRY" default:"24h"`
}

JWTConfig holds JWT configuration

func (*JWTConfig) GetAccessTokenExpiry

func (c *JWTConfig) GetAccessTokenExpiry() time.Duration

GetAccessTokenExpiry returns access token expiry duration

func (*JWTConfig) GetAlgorithm

func (c *JWTConfig) GetAlgorithm() string

GetAlgorithm returns the JWT algorithm

func (*JWTConfig) GetAudience

func (c *JWTConfig) GetAudience() string

GetAudience returns the JWT audience

func (*JWTConfig) GetBlacklistTTL

func (c *JWTConfig) GetBlacklistTTL() time.Duration

GetBlacklistTTL returns the blacklist TTL

func (*JWTConfig) GetCookieDomain

func (c *JWTConfig) GetCookieDomain() string

GetCookieDomain returns the refresh token cookie domain

func (*JWTConfig) GetCookieMaxAge

func (c *JWTConfig) GetCookieMaxAge() int

GetCookieMaxAge returns the cookie max age in seconds

func (*JWTConfig) GetCookieName

func (c *JWTConfig) GetCookieName() string

GetCookieName returns the refresh token cookie name

func (*JWTConfig) GetCookiePath

func (c *JWTConfig) GetCookiePath() string

GetCookiePath returns the refresh token cookie path

func (*JWTConfig) GetCookieSameSite

func (c *JWTConfig) GetCookieSameSite() string

GetCookieSameSite returns the cookie SameSite setting

func (*JWTConfig) GetEmailVerificationExpiry

func (c *JWTConfig) GetEmailVerificationExpiry() time.Duration

GetEmailVerificationExpiry returns the email verification token expiry

func (*JWTConfig) GetIssuer

func (c *JWTConfig) GetIssuer() string

GetIssuer returns the JWT issuer

func (*JWTConfig) GetPasswordResetExpiry

func (c *JWTConfig) GetPasswordResetExpiry() time.Duration

GetPasswordResetExpiry returns the password reset token expiry

func (*JWTConfig) GetRefreshThreshold

func (c *JWTConfig) GetRefreshThreshold() time.Duration

GetRefreshThreshold returns the refresh threshold

func (*JWTConfig) GetRefreshTokenExpiry

func (c *JWTConfig) GetRefreshTokenExpiry() time.Duration

GetRefreshTokenExpiry returns refresh token expiry duration

func (*JWTConfig) GetTokenRateLimitBurst

func (c *JWTConfig) GetTokenRateLimitBurst() int

GetTokenRateLimitBurst returns the token rate limit burst

func (*JWTConfig) GetTokenRateLimitRPS

func (c *JWTConfig) GetTokenRateLimitRPS() int

GetTokenRateLimitRPS returns the token rate limit RPS

func (*JWTConfig) GetTokenRateLimitWindow

func (c *JWTConfig) GetTokenRateLimitWindow() time.Duration

GetTokenRateLimitWindow returns the token rate limit window

func (*JWTConfig) GetTwoFactorExpiry

func (c *JWTConfig) GetTwoFactorExpiry() time.Duration

GetTwoFactorExpiry returns the 2FA token expiry

func (*JWTConfig) IsBlacklistEnabled

func (c *JWTConfig) IsBlacklistEnabled() bool

IsBlacklistEnabled returns whether token blacklisting is enabled

func (*JWTConfig) IsCookieHTTPOnly

func (c *JWTConfig) IsCookieHTTPOnly() bool

IsCookieHTTPOnly returns whether the cookie should be HTTP only

func (*JWTConfig) IsCookieSecure

func (c *JWTConfig) IsCookieSecure() bool

IsCookieSecure returns whether the cookie should be secure

func (*JWTConfig) IsTokenRateLimitEnabled

func (c *JWTConfig) IsTokenRateLimitEnabled() bool

IsTokenRateLimitEnabled returns whether token rate limiting is enabled

func (*JWTConfig) IsTwoFactorEnabled

func (c *JWTConfig) IsTwoFactorEnabled() bool

IsTwoFactorEnabled returns whether 2FA is enabled

type MailConfig

type MailConfig struct {
	// Driver settings
	Driver string `env:"MAIL_DRIVER" default:"smtp" required:"true"`

	// SMTP settings
	SMTPHost       string `env:"MAIL_HOST" default:"localhost"`
	SMTPPort       int    `env:"MAIL_PORT" default:"587"`
	SMTPUsername   string `env:"MAIL_USERNAME" default:""`
	SMTPPassword   string `env:"MAIL_PASSWORD" default:""`
	SMTPEncryption string `env:"MAIL_ENCRYPTION" default:"tls"`

	// From address
	FromAddress string `env:"MAIL_FROM_ADDRESS" default:"noreply@example.com" required:"true"`
	FromName    string `env:"MAIL_FROM_NAME" default:"Mithril App"`

	// SendGrid settings
	SendGridAPIKey string `env:"SENDGRID_API_KEY" default:""`

	// Mailgun settings
	MailgunDomain string `env:"MAILGUN_DOMAIN" default:""`
	MailgunAPIKey string `env:"MAILGUN_API_KEY" default:""`

	// Queue settings
	QueueEnabled bool          `env:"MAIL_QUEUE_ENABLED" default:"true"`
	QueueName    string        `env:"MAIL_QUEUE_NAME" default:"emails"`
	QueueTimeout time.Duration `env:"MAIL_QUEUE_TIMEOUT" default:"30s"`

	// Retry settings
	MaxRetries int           `env:"MAIL_MAX_RETRIES" default:"3"`
	RetryDelay time.Duration `env:"MAIL_RETRY_DELAY" default:"5s"`

	// Rate limiting
	RateLimitEnabled bool          `env:"MAIL_RATE_LIMIT_ENABLED" default:"true"`
	RateLimitRPS     int           `env:"MAIL_RATE_LIMIT_RPS" default:"10"`
	RateLimitBurst   int           `env:"MAIL_RATE_LIMIT_BURST" default:"20"`
	RateLimitWindow  time.Duration `env:"MAIL_RATE_LIMIT_WINDOW" default:"1m"`

	// Template settings
	TemplatePath string `env:"MAIL_TEMPLATE_PATH" default:"./templates/emails"`

	// Testing settings
	TestingEnabled bool   `env:"MAIL_TESTING_ENABLED" default:"false"`
	TestingEmail   string `env:"MAIL_TESTING_EMAIL" default:""`

	// Logging
	LogEnabled bool   `env:"MAIL_LOG_ENABLED" default:"true"`
	LogLevel   string `env:"MAIL_LOG_LEVEL" default:"info"`

	// Timeout settings
	ConnectTimeout time.Duration `env:"MAIL_CONNECT_TIMEOUT" default:"10s"`
	SendTimeout    time.Duration `env:"MAIL_SEND_TIMEOUT" default:"30s"`

	// Authentication
	AuthEnabled bool   `env:"MAIL_AUTH_ENABLED" default:"true"`
	AuthMethod  string `env:"MAIL_AUTH_METHOD" default:"PLAIN"`

	// TLS settings
	TLSEnabled            bool `env:"MAIL_TLS_ENABLED" default:"true"`
	TLSInsecureSkipVerify bool `env:"MAIL_TLS_INSECURE_SKIP_VERIFY" default:"false"`

	// Keep alive
	KeepAlive        bool          `env:"MAIL_KEEP_ALIVE" default:"true"`
	KeepAliveTimeout time.Duration `env:"MAIL_KEEP_ALIVE_TIMEOUT" default:"30s"`
}

MailConfig holds mail configuration

func (*MailConfig) GetAuthMethod

func (c *MailConfig) GetAuthMethod() string

GetAuthMethod returns the authentication method

func (*MailConfig) GetConnectTimeout

func (c *MailConfig) GetConnectTimeout() time.Duration

GetConnectTimeout returns the connection timeout

func (*MailConfig) GetDriver

func (c *MailConfig) GetDriver() string

GetDriver returns the mail driver

func (*MailConfig) GetFromAddress

func (c *MailConfig) GetFromAddress() string

GetFromAddress returns the from address

func (*MailConfig) GetFromName

func (c *MailConfig) GetFromName() string

GetFromName returns the from name

func (*MailConfig) GetKeepAliveTimeout

func (c *MailConfig) GetKeepAliveTimeout() time.Duration

GetKeepAliveTimeout returns the keep alive timeout

func (*MailConfig) GetLogLevel

func (c *MailConfig) GetLogLevel() string

GetLogLevel returns the log level

func (*MailConfig) GetMailgunAPIKey

func (c *MailConfig) GetMailgunAPIKey() string

GetMailgunAPIKey returns the Mailgun API key

func (*MailConfig) GetMailgunDomain

func (c *MailConfig) GetMailgunDomain() string

GetMailgunDomain returns the Mailgun domain

func (*MailConfig) GetMaxRetries

func (c *MailConfig) GetMaxRetries() int

GetMaxRetries returns the maximum number of retries

func (*MailConfig) GetQueueName

func (c *MailConfig) GetQueueName() string

GetQueueName returns the queue name

func (*MailConfig) GetQueueTimeout

func (c *MailConfig) GetQueueTimeout() time.Duration

GetQueueTimeout returns the queue timeout

func (*MailConfig) GetRateLimitBurst

func (c *MailConfig) GetRateLimitBurst() int

GetRateLimitBurst returns the rate limit burst

func (*MailConfig) GetRateLimitRPS

func (c *MailConfig) GetRateLimitRPS() int

GetRateLimitRPS returns the rate limit RPS

func (*MailConfig) GetRateLimitWindow

func (c *MailConfig) GetRateLimitWindow() time.Duration

GetRateLimitWindow returns the rate limit window

func (*MailConfig) GetRetryDelay

func (c *MailConfig) GetRetryDelay() time.Duration

GetRetryDelay returns the retry delay

func (*MailConfig) GetSMTPEncryption

func (c *MailConfig) GetSMTPEncryption() string

GetSMTPEncryption returns the SMTP encryption method

func (*MailConfig) GetSMTPHost

func (c *MailConfig) GetSMTPHost() string

GetSMTPHost returns the SMTP host

func (*MailConfig) GetSMTPPassword

func (c *MailConfig) GetSMTPPassword() string

GetSMTPPassword returns the SMTP password

func (*MailConfig) GetSMTPPort

func (c *MailConfig) GetSMTPPort() int

GetSMTPPort returns the SMTP port

func (*MailConfig) GetSMTPUsername

func (c *MailConfig) GetSMTPUsername() string

GetSMTPUsername returns the SMTP username

func (*MailConfig) GetSendGridAPIKey

func (c *MailConfig) GetSendGridAPIKey() string

GetSendGridAPIKey returns the SendGrid API key

func (*MailConfig) GetSendTimeout

func (c *MailConfig) GetSendTimeout() time.Duration

GetSendTimeout returns the send timeout

func (*MailConfig) GetTemplatePath

func (c *MailConfig) GetTemplatePath() string

GetTemplatePath returns the template path

func (*MailConfig) GetTestingEmail

func (c *MailConfig) GetTestingEmail() string

GetTestingEmail returns the testing email

func (*MailConfig) IsAuthEnabled

func (c *MailConfig) IsAuthEnabled() bool

IsAuthEnabled returns whether authentication is enabled

func (*MailConfig) IsKeepAlive

func (c *MailConfig) IsKeepAlive() bool

IsKeepAlive returns whether to keep connections alive

func (*MailConfig) IsLogEnabled

func (c *MailConfig) IsLogEnabled() bool

IsLogEnabled returns whether logging is enabled

func (*MailConfig) IsMailgun

func (c *MailConfig) IsMailgun() bool

IsMailgun returns true if using Mailgun driver

func (*MailConfig) IsQueueEnabled

func (c *MailConfig) IsQueueEnabled() bool

IsQueueEnabled returns whether queuing is enabled

func (*MailConfig) IsRateLimitEnabled

func (c *MailConfig) IsRateLimitEnabled() bool

IsRateLimitEnabled returns whether rate limiting is enabled

func (*MailConfig) IsSMTP

func (c *MailConfig) IsSMTP() bool

IsSMTP returns true if using SMTP driver

func (*MailConfig) IsSendGrid

func (c *MailConfig) IsSendGrid() bool

IsSendGrid returns true if using SendGrid driver

func (*MailConfig) IsTLSEnabled

func (c *MailConfig) IsTLSEnabled() bool

IsTLSEnabled returns whether TLS is enabled

func (*MailConfig) IsTLSInsecureSkipVerify

func (c *MailConfig) IsTLSInsecureSkipVerify() bool

IsTLSInsecureSkipVerify returns whether to skip TLS verification

func (*MailConfig) IsTestingEnabled

func (c *MailConfig) IsTestingEnabled() bool

IsTestingEnabled returns whether testing mode is enabled

type Manager

type Manager struct {
	App       *AppConfig
	Database  *DatabaseConfig
	JWT       *JWTConfig
	Mail      *MailConfig
	Queue     *QueueConfig
	Storage   *StorageConfig
	CORS      *CORSConfig
	RateLimit *RateLimitConfig
	Session   *SessionConfig
	// contains filtered or unexported fields
}

Manager holds all configuration instances

func NewManager

func NewManager(envFile string) (*Manager, error)

NewManager creates a new configuration manager

func NewManagerFromDir

func NewManagerFromDir(dir string) (*Manager, error)

NewManagerFromDir creates a new configuration manager from a directory

func NewManagerFromEnv

func NewManagerFromEnv() (*Manager, error)

NewManagerFromEnv creates a new configuration manager from environment

func NewManagerFromFile

func NewManagerFromFile(envFile string) (*Manager, error)

NewManagerFromFile creates a new configuration manager from a specific file

func (*Manager) GetAppConfig

func (m *Manager) GetAppConfig() *AppConfig

GetAppConfig returns the app configuration

func (*Manager) GetCORSConfig

func (m *Manager) GetCORSConfig() *CORSConfig

GetCORSConfig returns the CORS configuration

func (*Manager) GetConfig

func (m *Manager) GetConfig(name string) (interface{}, bool)

GetConfig returns a configuration by name

func (*Manager) GetDatabaseConfig

func (m *Manager) GetDatabaseConfig() *DatabaseConfig

GetDatabaseConfig returns the database configuration

func (*Manager) GetEnvironment

func (m *Manager) GetEnvironment() string

GetEnvironment returns the current environment

func (*Manager) GetJWTConfig

func (m *Manager) GetJWTConfig() *JWTConfig

GetJWTConfig returns the JWT configuration

func (*Manager) GetMailConfig

func (m *Manager) GetMailConfig() *MailConfig

GetMailConfig returns the mail configuration

func (*Manager) GetQueueConfig

func (m *Manager) GetQueueConfig() *QueueConfig

GetQueueConfig returns the queue configuration

func (*Manager) GetRateLimitConfig

func (m *Manager) GetRateLimitConfig() *RateLimitConfig

GetRateLimitConfig returns the rate limit configuration

func (*Manager) GetSessionConfig

func (m *Manager) GetSessionConfig() *SessionConfig

GetSessionConfig returns the session configuration

func (*Manager) GetStorageConfig

func (m *Manager) GetStorageConfig() *StorageConfig

GetStorageConfig returns the storage configuration

func (*Manager) GetTypedConfig

func (m *Manager) GetTypedConfig(name string, target interface{}) error

GetTypedConfig returns a typed configuration

func (*Manager) IsDevelopment

func (m *Manager) IsDevelopment() bool

IsDevelopment returns true if in development mode

func (*Manager) IsProduction

func (m *Manager) IsProduction() bool

IsProduction returns true if in production mode

func (*Manager) IsStaging

func (m *Manager) IsStaging() bool

IsStaging returns true if in staging mode

func (*Manager) IsTesting

func (m *Manager) IsTesting() bool

IsTesting returns true if in testing mode

func (*Manager) Reload

func (m *Manager) Reload() error

Reload reloads all configurations

func (*Manager) SetCORSConfig

func (m *Manager) SetCORSConfig(config *CORSConfig)

SetCORSConfig sets the CORS configuration

func (*Manager) SetDatabaseConfig

func (m *Manager) SetDatabaseConfig(config *DatabaseConfig)

SetDatabaseConfig sets the database configuration

func (*Manager) SetDebug

func (m *Manager) SetDebug(debug bool)

SetDebug sets the debug mode

func (*Manager) SetEnvironment

func (m *Manager) SetEnvironment(env string)

SetEnvironment sets the environment

func (*Manager) SetHost

func (m *Manager) SetHost(host string)

SetHost sets the host

func (*Manager) SetJWTConfig

func (m *Manager) SetJWTConfig(config *JWTConfig)

SetJWTConfig sets the JWT configuration

func (*Manager) SetMailConfig

func (m *Manager) SetMailConfig(config *MailConfig)

SetMailConfig sets the mail configuration

func (*Manager) SetPort

func (m *Manager) SetPort(port string)

SetPort sets the port

func (*Manager) SetQueueConfig

func (m *Manager) SetQueueConfig(config *QueueConfig)

SetQueueConfig sets the queue configuration

func (*Manager) SetRateLimitConfig

func (m *Manager) SetRateLimitConfig(config *RateLimitConfig)

SetRateLimitConfig sets the rate limit configuration

func (*Manager) SetSecretKey

func (m *Manager) SetSecretKey(secretKey string)

SetSecretKey sets the secret key

func (*Manager) SetSessionConfig

func (m *Manager) SetSessionConfig(config *SessionConfig)

SetSessionConfig sets the session configuration

func (*Manager) SetStorageConfig

func (m *Manager) SetStorageConfig(config *StorageConfig)

SetStorageConfig sets the storage configuration

func (*Manager) Validate

func (m *Manager) Validate() error

Validate validates all configurations

type QueueConfig

type QueueConfig struct {
	// Driver settings
	Driver string `env:"QUEUE_DRIVER" default:"memory" required:"true"`

	// Connection settings
	Connection string `env:"QUEUE_CONNECTION" default:"default"`

	// Redis settings
	RedisHost     string `env:"QUEUE_REDIS_HOST" default:"localhost"`
	RedisPort     int    `env:"QUEUE_REDIS_PORT" default:"6379"`
	RedisPassword string `env:"QUEUE_REDIS_PASSWORD" default:""`
	RedisDB       int    `env:"QUEUE_REDIS_DB" default:"1"`

	// RabbitMQ settings
	RabbitMQHost     string `env:"QUEUE_RABBITMQ_HOST" default:"localhost"`
	RabbitMQPort     int    `env:"QUEUE_RABBITMQ_PORT" default:"5672"`
	RabbitMQUsername string `env:"QUEUE_RABBITMQ_USERNAME" default:"guest"`
	RabbitMQPassword string `env:"QUEUE_RABBITMQ_PASSWORD" default:"guest"`
	RabbitMQVHost    string `env:"QUEUE_RABBITMQ_VHOST" default:"/"`

	// Kafka settings
	KafkaBrokers []string `env:"QUEUE_KAFKA_BROKERS" default:"localhost:9092"`

	// Queue settings
	DefaultQueue string `env:"QUEUE_DEFAULT" default:"default"`
	FailedQueue  string `env:"QUEUE_FAILED" default:"failed"`

	// Worker settings
	MaxWorkers    int           `env:"QUEUE_MAX_WORKERS" default:"10"`
	WorkerTimeout time.Duration `env:"QUEUE_WORKER_TIMEOUT" default:"30s"`
	WorkerSleep   time.Duration `env:"QUEUE_WORKER_SLEEP" default:"3s"`

	// Job settings
	MaxRetries    int           `env:"QUEUE_MAX_RETRIES" default:"3"`
	RetryDelay    time.Duration `env:"QUEUE_RETRY_DELAY" default:"5s"`
	RetryBackoff  bool          `env:"QUEUE_RETRY_BACKOFF" default:"true"`
	RetryMaxDelay time.Duration `env:"QUEUE_RETRY_MAX_DELAY" default:"1h"`

	// Job timeout
	JobTimeout time.Duration `env:"QUEUE_JOB_TIMEOUT" default:"5m"`

	// Dead letter queue
	DeadLetterEnabled bool   `env:"QUEUE_DEAD_LETTER_ENABLED" default:"true"`
	DeadLetterQueue   string `env:"QUEUE_DEAD_LETTER_QUEUE" default:"dead_letter"`

	// Monitoring
	MonitoringEnabled bool   `env:"QUEUE_MONITORING_ENABLED" default:"true"`
	MonitoringPath    string `env:"QUEUE_MONITORING_PATH" default:"/monitor/queue"`

	// Metrics
	MetricsEnabled bool   `env:"QUEUE_METRICS_ENABLED" default:"true"`
	MetricsPath    string `env:"QUEUE_METRICS_PATH" default:"/metrics/queue"`

	// Logging
	LogEnabled bool   `env:"QUEUE_LOG_ENABLED" default:"true"`
	LogLevel   string `env:"QUEUE_LOG_LEVEL" default:"info"`

	// Batch processing
	BatchSize    int           `env:"QUEUE_BATCH_SIZE" default:"100"`
	BatchTimeout time.Duration `env:"QUEUE_BATCH_TIMEOUT" default:"1s"`

	// Priority queues
	PriorityEnabled bool `env:"QUEUE_PRIORITY_ENABLED" default:"false"`
	MaxPriority     int  `env:"QUEUE_MAX_PRIORITY" default:"10"`

	// Rate limiting
	RateLimitEnabled bool          `env:"QUEUE_RATE_LIMIT_ENABLED" default:"false"`
	RateLimitRPS     int           `env:"QUEUE_RATE_LIMIT_RPS" default:"100"`
	RateLimitBurst   int           `env:"QUEUE_RATE_LIMIT_BURST" default:"200"`
	RateLimitWindow  time.Duration `env:"QUEUE_RATE_LIMIT_WINDOW" default:"1m"`

	// Health check
	HealthCheckEnabled  bool          `env:"QUEUE_HEALTH_CHECK_ENABLED" default:"true"`
	HealthCheckInterval time.Duration `env:"QUEUE_HEALTH_CHECK_INTERVAL" default:"30s"`
}

QueueConfig holds queue configuration

func (*QueueConfig) GetBatchSize

func (c *QueueConfig) GetBatchSize() int

GetBatchSize returns the batch size

func (*QueueConfig) GetBatchTimeout

func (c *QueueConfig) GetBatchTimeout() time.Duration

GetBatchTimeout returns the batch timeout

func (*QueueConfig) GetConnection

func (c *QueueConfig) GetConnection() string

GetConnection returns the queue connection

func (*QueueConfig) GetDeadLetterQueue

func (c *QueueConfig) GetDeadLetterQueue() string

GetDeadLetterQueue returns the dead letter queue name

func (*QueueConfig) GetDefaultQueue

func (c *QueueConfig) GetDefaultQueue() string

GetDefaultQueue returns the default queue name

func (*QueueConfig) GetDriver

func (c *QueueConfig) GetDriver() string

GetDriver returns the queue driver

func (*QueueConfig) GetFailedQueue

func (c *QueueConfig) GetFailedQueue() string

GetFailedQueue returns the failed queue name

func (*QueueConfig) GetHealthCheckInterval

func (c *QueueConfig) GetHealthCheckInterval() time.Duration

GetHealthCheckInterval returns the health check interval

func (*QueueConfig) GetJobTimeout

func (c *QueueConfig) GetJobTimeout() time.Duration

GetJobTimeout returns the job timeout

func (*QueueConfig) GetKafkaBrokers

func (c *QueueConfig) GetKafkaBrokers() []string

GetKafkaBrokers returns the Kafka brokers

func (*QueueConfig) GetLogLevel

func (c *QueueConfig) GetLogLevel() string

GetLogLevel returns the log level

func (*QueueConfig) GetMaxPriority

func (c *QueueConfig) GetMaxPriority() int

GetMaxPriority returns the maximum priority

func (*QueueConfig) GetMaxRetries

func (c *QueueConfig) GetMaxRetries() int

GetMaxRetries returns the maximum number of retries

func (*QueueConfig) GetMaxWorkers

func (c *QueueConfig) GetMaxWorkers() int

GetMaxWorkers returns the maximum number of workers

func (*QueueConfig) GetMetricsPath

func (c *QueueConfig) GetMetricsPath() string

GetMetricsPath returns the metrics path

func (*QueueConfig) GetMonitoringPath

func (c *QueueConfig) GetMonitoringPath() string

GetMonitoringPath returns the monitoring path

func (*QueueConfig) GetRabbitMQHost

func (c *QueueConfig) GetRabbitMQHost() string

GetRabbitMQHost returns the RabbitMQ host

func (*QueueConfig) GetRabbitMQPassword

func (c *QueueConfig) GetRabbitMQPassword() string

GetRabbitMQPassword returns the RabbitMQ password

func (*QueueConfig) GetRabbitMQPort

func (c *QueueConfig) GetRabbitMQPort() int

GetRabbitMQPort returns the RabbitMQ port

func (*QueueConfig) GetRabbitMQURL

func (c *QueueConfig) GetRabbitMQURL() string

GetRabbitMQURL returns the RabbitMQ connection URL

func (*QueueConfig) GetRabbitMQUsername

func (c *QueueConfig) GetRabbitMQUsername() string

GetRabbitMQUsername returns the RabbitMQ username

func (*QueueConfig) GetRabbitMQVHost

func (c *QueueConfig) GetRabbitMQVHost() string

GetRabbitMQVHost returns the RabbitMQ virtual host

func (*QueueConfig) GetRateLimitBurst

func (c *QueueConfig) GetRateLimitBurst() int

GetRateLimitBurst returns the rate limit burst

func (*QueueConfig) GetRateLimitRPS

func (c *QueueConfig) GetRateLimitRPS() int

GetRateLimitRPS returns the rate limit RPS

func (*QueueConfig) GetRateLimitWindow

func (c *QueueConfig) GetRateLimitWindow() time.Duration

GetRateLimitWindow returns the rate limit window

func (*QueueConfig) GetRedisAddr

func (c *QueueConfig) GetRedisAddr() string

GetRedisAddr returns the Redis address

func (*QueueConfig) GetRedisDB

func (c *QueueConfig) GetRedisDB() int

GetRedisDB returns the Redis database number

func (*QueueConfig) GetRedisHost

func (c *QueueConfig) GetRedisHost() string

GetRedisHost returns the Redis host

func (*QueueConfig) GetRedisPassword

func (c *QueueConfig) GetRedisPassword() string

GetRedisPassword returns the Redis password

func (*QueueConfig) GetRedisPort

func (c *QueueConfig) GetRedisPort() int

GetRedisPort returns the Redis port

func (*QueueConfig) GetRetryDelay

func (c *QueueConfig) GetRetryDelay() time.Duration

GetRetryDelay returns the retry delay

func (*QueueConfig) GetRetryMaxDelay

func (c *QueueConfig) GetRetryMaxDelay() time.Duration

GetRetryMaxDelay returns the maximum retry delay

func (*QueueConfig) GetWorkerSleep

func (c *QueueConfig) GetWorkerSleep() time.Duration

GetWorkerSleep returns the worker sleep duration

func (*QueueConfig) GetWorkerTimeout

func (c *QueueConfig) GetWorkerTimeout() time.Duration

GetWorkerTimeout returns the worker timeout

func (*QueueConfig) IsDeadLetterEnabled

func (c *QueueConfig) IsDeadLetterEnabled() bool

IsDeadLetterEnabled returns whether dead letter queue is enabled

func (*QueueConfig) IsHealthCheckEnabled

func (c *QueueConfig) IsHealthCheckEnabled() bool

IsHealthCheckEnabled returns whether health check is enabled

func (*QueueConfig) IsKafka

func (c *QueueConfig) IsKafka() bool

IsKafka returns true if using Kafka driver

func (*QueueConfig) IsLogEnabled

func (c *QueueConfig) IsLogEnabled() bool

IsLogEnabled returns whether logging is enabled

func (*QueueConfig) IsMemory

func (c *QueueConfig) IsMemory() bool

IsMemory returns true if using memory driver

func (*QueueConfig) IsMetricsEnabled

func (c *QueueConfig) IsMetricsEnabled() bool

IsMetricsEnabled returns whether metrics are enabled

func (*QueueConfig) IsMonitoringEnabled

func (c *QueueConfig) IsMonitoringEnabled() bool

IsMonitoringEnabled returns whether monitoring is enabled

func (*QueueConfig) IsPriorityEnabled

func (c *QueueConfig) IsPriorityEnabled() bool

IsPriorityEnabled returns whether priority queues are enabled

func (*QueueConfig) IsRabbitMQ

func (c *QueueConfig) IsRabbitMQ() bool

IsRabbitMQ returns true if using RabbitMQ driver

func (*QueueConfig) IsRateLimitEnabled

func (c *QueueConfig) IsRateLimitEnabled() bool

IsRateLimitEnabled returns whether rate limiting is enabled

func (*QueueConfig) IsRedis

func (c *QueueConfig) IsRedis() bool

IsRedis returns true if using Redis driver

func (*QueueConfig) IsRetryBackoff

func (c *QueueConfig) IsRetryBackoff() bool

IsRetryBackoff returns whether retry backoff is enabled

type RateLimitConfig

type RateLimitConfig struct {
	// Global settings
	Enabled bool `env:"RATE_LIMIT_ENABLED" default:"true"`

	// Default rate limit settings
	DefaultRPS    int           `env:"RATE_LIMIT_DEFAULT_RPS" default:"100"`
	DefaultBurst  int           `env:"RATE_LIMIT_DEFAULT_BURST" default:"200"`
	DefaultWindow time.Duration `env:"RATE_LIMIT_DEFAULT_WINDOW" default:"1m"`

	// IP-based rate limiting
	IPEnabled bool          `env:"RATE_LIMIT_IP_ENABLED" default:"true"`
	IPRPS     int           `env:"RATE_LIMIT_IP_RPS" default:"100"`
	IPBurst   int           `env:"RATE_LIMIT_IP_BURST" default:"200"`
	IPWindow  time.Duration `env:"RATE_LIMIT_IP_WINDOW" default:"1m"`

	// User-based rate limiting
	UserEnabled bool          `env:"RATE_LIMIT_USER_ENABLED" default:"true"`
	UserRPS     int           `env:"RATE_LIMIT_USER_RPS" default:"50"`
	UserBurst   int           `env:"RATE_LIMIT_USER_BURST" default:"100"`
	UserWindow  time.Duration `env:"RATE_LIMIT_USER_WINDOW" default:"1m"`

	// Route-based rate limiting
	RouteEnabled bool          `env:"RATE_LIMIT_ROUTE_ENABLED" default:"true"`
	RouteRPS     int           `env:"RATE_LIMIT_ROUTE_RPS" default:"200"`
	RouteBurst   int           `env:"RATE_LIMIT_ROUTE_BURST" default:"400"`
	RouteWindow  time.Duration `env:"RATE_LIMIT_ROUTE_WINDOW" default:"1m"`

	// API rate limiting
	APIEnabled bool          `env:"RATE_LIMIT_API_ENABLED" default:"true"`
	APIRPS     int           `env:"RATE_LIMIT_API_RPS" default:"1000"`
	APIBurst   int           `env:"RATE_LIMIT_API_BURST" default:"2000"`
	APIWindow  time.Duration `env:"RATE_LIMIT_API_WINDOW" default:"1m"`

	// Auth rate limiting
	AuthEnabled bool          `env:"RATE_LIMIT_AUTH_ENABLED" default:"true"`
	AuthRPS     int           `env:"RATE_LIMIT_AUTH_RPS" default:"5"`
	AuthBurst   int           `env:"RATE_LIMIT_AUTH_BURST" default:"10"`
	AuthWindow  time.Duration `env:"RATE_LIMIT_AUTH_WINDOW" default:"1m"`

	// Upload rate limiting
	UploadEnabled bool          `env:"RATE_LIMIT_UPLOAD_ENABLED" default:"true"`
	UploadRPS     int           `env:"RATE_LIMIT_UPLOAD_RPS" default:"10"`
	UploadBurst   int           `env:"RATE_LIMIT_UPLOAD_BURST" default:"20"`
	UploadWindow  time.Duration `env:"RATE_LIMIT_UPLOAD_WINDOW" default:"1m"`

	// Storage settings
	StorageDriver string `env:"RATE_LIMIT_STORAGE_DRIVER" default:"memory"`
	StoragePath   string `env:"RATE_LIMIT_STORAGE_PATH" default:"./storage/ratelimit"`

	// Redis settings (if using Redis storage)
	RedisHost     string `env:"RATE_LIMIT_REDIS_HOST" default:"localhost"`
	RedisPort     int    `env:"RATE_LIMIT_REDIS_PORT" default:"6379"`
	RedisPassword string `env:"RATE_LIMIT_REDIS_PASSWORD" default:""`
	RedisDB       int    `env:"RATE_LIMIT_REDIS_DB" default:"2"`

	// Cleanup settings
	CleanupEnabled  bool          `env:"RATE_LIMIT_CLEANUP_ENABLED" default:"true"`
	CleanupInterval time.Duration `env:"RATE_LIMIT_CLEANUP_INTERVAL" default:"5m"`

	// Monitoring
	MonitoringEnabled bool   `env:"RATE_LIMIT_MONITORING_ENABLED" default:"true"`
	MonitoringPath    string `env:"RATE_LIMIT_MONITORING_PATH" default:"/monitor/ratelimit"`

	// Metrics
	MetricsEnabled bool   `env:"RATE_LIMIT_METRICS_ENABLED" default:"true"`
	MetricsPath    string `env:"RATE_LIMIT_METRICS_PATH" default:"/metrics/ratelimit"`

	// Logging
	LogEnabled bool   `env:"RATE_LIMIT_LOG_ENABLED" default:"true"`
	LogLevel   string `env:"RATE_LIMIT_LOG_LEVEL" default:"info"`

	// Health check
	HealthCheckEnabled  bool          `env:"RATE_LIMIT_HEALTH_CHECK_ENABLED" default:"true"`
	HealthCheckInterval time.Duration `env:"RATE_LIMIT_HEALTH_CHECK_INTERVAL" default:"30s"`

	// Whitelist settings
	WhitelistEnabled bool     `env:"RATE_LIMIT_WHITELIST_ENABLED" default:"false"`
	WhitelistIPs     []string `env:"RATE_LIMIT_WHITELIST_IPS" default:""`

	// Blacklist settings
	BlacklistEnabled bool     `env:"RATE_LIMIT_BLACKLIST_ENABLED" default:"false"`
	BlacklistIPs     []string `env:"RATE_LIMIT_BLACKLIST_IPS" default:""`

	// Custom rules
	CustomRulesEnabled bool `env:"RATE_LIMIT_CUSTOM_RULES_ENABLED" default:"false"`
}

RateLimitConfig holds rate limiting configuration

func (*RateLimitConfig) GetAPIBurst

func (c *RateLimitConfig) GetAPIBurst() int

GetAPIBurst returns the API burst

func (*RateLimitConfig) GetAPIRPS

func (c *RateLimitConfig) GetAPIRPS() int

GetAPIRPS returns the API RPS

func (*RateLimitConfig) GetAPIWindow

func (c *RateLimitConfig) GetAPIWindow() time.Duration

GetAPIWindow returns the API window

func (*RateLimitConfig) GetAuthBurst

func (c *RateLimitConfig) GetAuthBurst() int

GetAuthBurst returns the auth burst

func (*RateLimitConfig) GetAuthRPS

func (c *RateLimitConfig) GetAuthRPS() int

GetAuthRPS returns the auth RPS

func (*RateLimitConfig) GetAuthWindow

func (c *RateLimitConfig) GetAuthWindow() time.Duration

GetAuthWindow returns the auth window

func (*RateLimitConfig) GetBlacklistIPs

func (c *RateLimitConfig) GetBlacklistIPs() []string

GetBlacklistIPs returns the blacklist IPs

func (*RateLimitConfig) GetCleanupInterval

func (c *RateLimitConfig) GetCleanupInterval() time.Duration

GetCleanupInterval returns the cleanup interval

func (*RateLimitConfig) GetDefaultBurst

func (c *RateLimitConfig) GetDefaultBurst() int

GetDefaultBurst returns the default burst

func (*RateLimitConfig) GetDefaultRPS

func (c *RateLimitConfig) GetDefaultRPS() int

GetDefaultRPS returns the default RPS

func (*RateLimitConfig) GetDefaultWindow

func (c *RateLimitConfig) GetDefaultWindow() time.Duration

GetDefaultWindow returns the default window

func (*RateLimitConfig) GetHealthCheckInterval

func (c *RateLimitConfig) GetHealthCheckInterval() time.Duration

GetHealthCheckInterval returns the health check interval

func (*RateLimitConfig) GetIPBurst

func (c *RateLimitConfig) GetIPBurst() int

GetIPBurst returns the IP burst

func (*RateLimitConfig) GetIPRPS

func (c *RateLimitConfig) GetIPRPS() int

GetIPRPS returns the IP RPS

func (*RateLimitConfig) GetIPWindow

func (c *RateLimitConfig) GetIPWindow() time.Duration

GetIPWindow returns the IP window

func (*RateLimitConfig) GetLogLevel

func (c *RateLimitConfig) GetLogLevel() string

GetLogLevel returns the log level

func (*RateLimitConfig) GetMetricsPath

func (c *RateLimitConfig) GetMetricsPath() string

GetMetricsPath returns the metrics path

func (*RateLimitConfig) GetMonitoringPath

func (c *RateLimitConfig) GetMonitoringPath() string

GetMonitoringPath returns the monitoring path

func (*RateLimitConfig) GetRedisAddr

func (c *RateLimitConfig) GetRedisAddr() string

GetRedisAddr returns the Redis address

func (*RateLimitConfig) GetRedisDB

func (c *RateLimitConfig) GetRedisDB() int

GetRedisDB returns the Redis database number

func (*RateLimitConfig) GetRedisHost

func (c *RateLimitConfig) GetRedisHost() string

GetRedisHost returns the Redis host

func (*RateLimitConfig) GetRedisPassword

func (c *RateLimitConfig) GetRedisPassword() string

GetRedisPassword returns the Redis password

func (*RateLimitConfig) GetRedisPort

func (c *RateLimitConfig) GetRedisPort() int

GetRedisPort returns the Redis port

func (*RateLimitConfig) GetRouteBurst

func (c *RateLimitConfig) GetRouteBurst() int

GetRouteBurst returns the route burst

func (*RateLimitConfig) GetRouteRPS

func (c *RateLimitConfig) GetRouteRPS() int

GetRouteRPS returns the route RPS

func (*RateLimitConfig) GetRouteWindow

func (c *RateLimitConfig) GetRouteWindow() time.Duration

GetRouteWindow returns the route window

func (*RateLimitConfig) GetStorageDriver

func (c *RateLimitConfig) GetStorageDriver() string

GetStorageDriver returns the storage driver

func (*RateLimitConfig) GetStoragePath

func (c *RateLimitConfig) GetStoragePath() string

GetStoragePath returns the storage path

func (*RateLimitConfig) GetUploadBurst

func (c *RateLimitConfig) GetUploadBurst() int

GetUploadBurst returns the upload burst

func (*RateLimitConfig) GetUploadRPS

func (c *RateLimitConfig) GetUploadRPS() int

GetUploadRPS returns the upload RPS

func (*RateLimitConfig) GetUploadWindow

func (c *RateLimitConfig) GetUploadWindow() time.Duration

GetUploadWindow returns the upload window

func (*RateLimitConfig) GetUserBurst

func (c *RateLimitConfig) GetUserBurst() int

GetUserBurst returns the user burst

func (*RateLimitConfig) GetUserRPS

func (c *RateLimitConfig) GetUserRPS() int

GetUserRPS returns the user RPS

func (*RateLimitConfig) GetUserWindow

func (c *RateLimitConfig) GetUserWindow() time.Duration

GetUserWindow returns the user window

func (*RateLimitConfig) GetWhitelistIPs

func (c *RateLimitConfig) GetWhitelistIPs() []string

GetWhitelistIPs returns the whitelist IPs

func (*RateLimitConfig) IsAPIEnabled

func (c *RateLimitConfig) IsAPIEnabled() bool

IsAPIEnabled returns whether API rate limiting is enabled

func (*RateLimitConfig) IsAuthEnabled

func (c *RateLimitConfig) IsAuthEnabled() bool

IsAuthEnabled returns whether auth rate limiting is enabled

func (*RateLimitConfig) IsBlacklistEnabled

func (c *RateLimitConfig) IsBlacklistEnabled() bool

IsBlacklistEnabled returns whether blacklist is enabled

func (*RateLimitConfig) IsCleanupEnabled

func (c *RateLimitConfig) IsCleanupEnabled() bool

IsCleanupEnabled returns whether cleanup is enabled

func (*RateLimitConfig) IsCustomRulesEnabled

func (c *RateLimitConfig) IsCustomRulesEnabled() bool

IsCustomRulesEnabled returns whether custom rules are enabled

func (*RateLimitConfig) IsEnabled

func (c *RateLimitConfig) IsEnabled() bool

IsEnabled returns whether rate limiting is enabled

func (*RateLimitConfig) IsHealthCheckEnabled

func (c *RateLimitConfig) IsHealthCheckEnabled() bool

IsHealthCheckEnabled returns whether health check is enabled

func (*RateLimitConfig) IsIPBlacklisted

func (c *RateLimitConfig) IsIPBlacklisted(ip string) bool

IsIPBlacklisted checks if an IP is blacklisted

func (*RateLimitConfig) IsIPEnabled

func (c *RateLimitConfig) IsIPEnabled() bool

IsIPEnabled returns whether IP-based rate limiting is enabled

func (*RateLimitConfig) IsIPWhitelisted

func (c *RateLimitConfig) IsIPWhitelisted(ip string) bool

IsIPWhitelisted checks if an IP is whitelisted

func (*RateLimitConfig) IsLogEnabled

func (c *RateLimitConfig) IsLogEnabled() bool

IsLogEnabled returns whether logging is enabled

func (*RateLimitConfig) IsMemory

func (c *RateLimitConfig) IsMemory() bool

IsMemory returns true if using memory storage

func (*RateLimitConfig) IsMetricsEnabled

func (c *RateLimitConfig) IsMetricsEnabled() bool

IsMetricsEnabled returns whether metrics are enabled

func (*RateLimitConfig) IsMonitoringEnabled

func (c *RateLimitConfig) IsMonitoringEnabled() bool

IsMonitoringEnabled returns whether monitoring is enabled

func (*RateLimitConfig) IsRedis

func (c *RateLimitConfig) IsRedis() bool

IsRedis returns true if using Redis storage

func (*RateLimitConfig) IsRouteEnabled

func (c *RateLimitConfig) IsRouteEnabled() bool

IsRouteEnabled returns whether route-based rate limiting is enabled

func (*RateLimitConfig) IsUploadEnabled

func (c *RateLimitConfig) IsUploadEnabled() bool

IsUploadEnabled returns whether upload rate limiting is enabled

func (*RateLimitConfig) IsUserEnabled

func (c *RateLimitConfig) IsUserEnabled() bool

IsUserEnabled returns whether user-based rate limiting is enabled

func (*RateLimitConfig) IsWhitelistEnabled

func (c *RateLimitConfig) IsWhitelistEnabled() bool

IsWhitelistEnabled returns whether whitelist is enabled

type SessionConfig

type SessionConfig struct {
	// Basic settings
	Enabled        bool          `env:"SESSION_ENABLED" default:"true"`
	Driver         string        `env:"SESSION_DRIVER" default:"database" required:"true"`
	Lifetime       time.Duration `env:"SESSION_LIFETIME" default:"24h"`
	IdleTimeout    time.Duration `env:"SESSION_IDLE_TIMEOUT" default:"30m"`
	RefreshTimeout time.Duration `env:"SESSION_REFRESH_TIMEOUT" default:"5m"`

	// Cookie settings
	CookieName     string `env:"SESSION_COOKIE_NAME" default:"mithril_session"`
	CookiePath     string `env:"SESSION_COOKIE_PATH" default:"/"`
	CookieDomain   string `env:"SESSION_COOKIE_DOMAIN" default:""`
	CookieSecure   bool   `env:"SESSION_COOKIE_SECURE" default:"false"`
	CookieHTTPOnly bool   `env:"SESSION_COOKIE_HTTP_ONLY" default:"true"`
	CookieSameSite string `env:"SESSION_COOKIE_SAME_SITE" default:"Lax"`

	// Security settings
	SecretKey     string `env:"SESSION_SECRET_KEY" required:"true" min:"32"`
	EncryptionKey string `env:"SESSION_ENCRYPTION_KEY" default:""`
	HashKey       string `env:"SESSION_HASH_KEY" default:""`

	// Database settings (if using database driver)
	DBTable       string        `env:"SESSION_DB_TABLE" default:"sessions"`
	DBMaxIdle     int           `env:"SESSION_DB_MAX_IDLE" default:"10"`
	DBMaxOpen     int           `env:"SESSION_DB_MAX_OPEN" default:"100"`
	DBMaxLifetime time.Duration `env:"SESSION_DB_MAX_LIFETIME" default:"1h"`

	// Redis settings (if using Redis driver)
	RedisHost     string `env:"SESSION_REDIS_HOST" default:"localhost"`
	RedisPort     int    `env:"SESSION_REDIS_PORT" default:"6379"`
	RedisPassword string `env:"SESSION_REDIS_PASSWORD" default:""`
	RedisDB       int    `env:"SESSION_REDIS_DB" default:"3"`
	RedisPrefix   string `env:"SESSION_REDIS_PREFIX" default:"session:"`

	// File settings (if using file driver)
	FilePath string `env:"SESSION_FILE_PATH" default:"./storage/sessions"`

	// Memory settings (if using memory driver)
	MemoryMaxSessions int `env:"SESSION_MEMORY_MAX_SESSIONS" default:"10000"`

	// Cleanup settings
	CleanupEnabled   bool          `env:"SESSION_CLEANUP_ENABLED" default:"true"`
	CleanupInterval  time.Duration `env:"SESSION_CLEANUP_INTERVAL" default:"1h"`
	CleanupOlderThan time.Duration `env:"SESSION_CLEANUP_OLDER_THAN" default:"24h"`

	// Monitoring
	MonitoringEnabled bool   `env:"SESSION_MONITORING_ENABLED" default:"true"`
	MonitoringPath    string `env:"SESSION_MONITORING_PATH" default:"/monitor/session"`

	// Metrics
	MetricsEnabled bool   `env:"SESSION_METRICS_ENABLED" default:"true"`
	MetricsPath    string `env:"SESSION_METRICS_PATH" default:"/metrics/session"`

	// Logging
	LogEnabled bool   `env:"SESSION_LOG_ENABLED" default:"true"`
	LogLevel   string `env:"SESSION_LOG_LEVEL" default:"info"`

	// Health check
	HealthCheckEnabled  bool          `env:"SESSION_HEALTH_CHECK_ENABLED" default:"true"`
	HealthCheckInterval time.Duration `env:"SESSION_HEALTH_CHECK_INTERVAL" default:"30s"`

	// CSRF protection
	CSRFEnabled     bool   `env:"SESSION_CSRF_ENABLED" default:"true"`
	CSRFTokenLength int    `env:"SESSION_CSRF_TOKEN_LENGTH" default:"32"`
	CSRFHeaderName  string `env:"SESSION_CSRF_HEADER_NAME" default:"X-CSRF-Token"`

	// Flash messages
	FlashEnabled bool `env:"SESSION_FLASH_ENABLED" default:"true"`

	// Session regeneration
	RegenerateOnLogin  bool `env:"SESSION_REGENERATE_ON_LOGIN" default:"true"`
	RegenerateOnLogout bool `env:"SESSION_REGENERATE_ON_LOGOUT" default:"true"`

	// Session hijacking protection
	HijackingProtection bool `env:"SESSION_HIJACKING_PROTECTION" default:"true"`

	// Session fixation protection
	FixationProtection bool `env:"SESSION_FIXATION_PROTECTION" default:"true"`
}

SessionConfig holds session configuration

func (*SessionConfig) GetCSRFHeaderName

func (c *SessionConfig) GetCSRFHeaderName() string

GetCSRFHeaderName returns the CSRF header name

func (*SessionConfig) GetCSRFTokenLength

func (c *SessionConfig) GetCSRFTokenLength() int

GetCSRFTokenLength returns the CSRF token length

func (*SessionConfig) GetCleanupInterval

func (c *SessionConfig) GetCleanupInterval() time.Duration

GetCleanupInterval returns the cleanup interval

func (*SessionConfig) GetCleanupOlderThan

func (c *SessionConfig) GetCleanupOlderThan() time.Duration

GetCleanupOlderThan returns the cleanup older than duration

func (*SessionConfig) GetCookieDomain

func (c *SessionConfig) GetCookieDomain() string

GetCookieDomain returns the cookie domain

func (*SessionConfig) GetCookieName

func (c *SessionConfig) GetCookieName() string

GetCookieName returns the cookie name

func (*SessionConfig) GetCookiePath

func (c *SessionConfig) GetCookiePath() string

GetCookiePath returns the cookie path

func (*SessionConfig) GetCookieSameSite

func (c *SessionConfig) GetCookieSameSite() string

GetCookieSameSite returns the cookie SameSite setting

func (*SessionConfig) GetDBMaxIdle

func (c *SessionConfig) GetDBMaxIdle() int

GetDBMaxIdle returns the database max idle connections

func (*SessionConfig) GetDBMaxLifetime

func (c *SessionConfig) GetDBMaxLifetime() time.Duration

GetDBMaxLifetime returns the database max connection lifetime

func (*SessionConfig) GetDBMaxOpen

func (c *SessionConfig) GetDBMaxOpen() int

GetDBMaxOpen returns the database max open connections

func (*SessionConfig) GetDBTable

func (c *SessionConfig) GetDBTable() string

GetDBTable returns the database table name

func (*SessionConfig) GetDriver

func (c *SessionConfig) GetDriver() string

GetDriver returns the session driver

func (*SessionConfig) GetEncryptionKey

func (c *SessionConfig) GetEncryptionKey() string

GetEncryptionKey returns the encryption key

func (*SessionConfig) GetFilePath

func (c *SessionConfig) GetFilePath() string

GetFilePath returns the file path

func (*SessionConfig) GetHashKey

func (c *SessionConfig) GetHashKey() string

GetHashKey returns the hash key

func (*SessionConfig) GetHealthCheckInterval

func (c *SessionConfig) GetHealthCheckInterval() time.Duration

GetHealthCheckInterval returns the health check interval

func (*SessionConfig) GetIdleTimeout

func (c *SessionConfig) GetIdleTimeout() time.Duration

GetIdleTimeout returns the idle timeout

func (*SessionConfig) GetLifetime

func (c *SessionConfig) GetLifetime() time.Duration

GetLifetime returns the session lifetime

func (*SessionConfig) GetLogLevel

func (c *SessionConfig) GetLogLevel() string

GetLogLevel returns the log level

func (*SessionConfig) GetMemoryMaxSessions

func (c *SessionConfig) GetMemoryMaxSessions() int

GetMemoryMaxSessions returns the maximum number of sessions in memory

func (*SessionConfig) GetMetricsPath

func (c *SessionConfig) GetMetricsPath() string

GetMetricsPath returns the metrics path

func (*SessionConfig) GetMonitoringPath

func (c *SessionConfig) GetMonitoringPath() string

GetMonitoringPath returns the monitoring path

func (*SessionConfig) GetRedisAddr

func (c *SessionConfig) GetRedisAddr() string

GetRedisAddr returns the Redis address

func (*SessionConfig) GetRedisDB

func (c *SessionConfig) GetRedisDB() int

GetRedisDB returns the Redis database number

func (*SessionConfig) GetRedisHost

func (c *SessionConfig) GetRedisHost() string

GetRedisHost returns the Redis host

func (*SessionConfig) GetRedisPassword

func (c *SessionConfig) GetRedisPassword() string

GetRedisPassword returns the Redis password

func (*SessionConfig) GetRedisPort

func (c *SessionConfig) GetRedisPort() int

GetRedisPort returns the Redis port

func (*SessionConfig) GetRedisPrefix

func (c *SessionConfig) GetRedisPrefix() string

GetRedisPrefix returns the Redis prefix

func (*SessionConfig) GetRefreshTimeout

func (c *SessionConfig) GetRefreshTimeout() time.Duration

GetRefreshTimeout returns the refresh timeout

func (*SessionConfig) GetSecretKey

func (c *SessionConfig) GetSecretKey() string

GetSecretKey returns the secret key

func (*SessionConfig) IsCSRFEnabled

func (c *SessionConfig) IsCSRFEnabled() bool

IsCSRFEnabled returns whether CSRF protection is enabled

func (*SessionConfig) IsCleanupEnabled

func (c *SessionConfig) IsCleanupEnabled() bool

IsCleanupEnabled returns whether cleanup is enabled

func (*SessionConfig) IsCookieHTTPOnly

func (c *SessionConfig) IsCookieHTTPOnly() bool

IsCookieHTTPOnly returns whether the cookie should be HTTP only

func (*SessionConfig) IsCookieSecure

func (c *SessionConfig) IsCookieSecure() bool

IsCookieSecure returns whether the cookie should be secure

func (*SessionConfig) IsDatabase

func (c *SessionConfig) IsDatabase() bool

IsDatabase returns true if using database driver

func (*SessionConfig) IsEnabled

func (c *SessionConfig) IsEnabled() bool

IsEnabled returns whether sessions are enabled

func (*SessionConfig) IsFile

func (c *SessionConfig) IsFile() bool

IsFile returns true if using file driver

func (*SessionConfig) IsFixationProtection

func (c *SessionConfig) IsFixationProtection() bool

IsFixationProtection returns whether fixation protection is enabled

func (*SessionConfig) IsFlashEnabled

func (c *SessionConfig) IsFlashEnabled() bool

IsFlashEnabled returns whether flash messages are enabled

func (*SessionConfig) IsHealthCheckEnabled

func (c *SessionConfig) IsHealthCheckEnabled() bool

IsHealthCheckEnabled returns whether health check is enabled

func (*SessionConfig) IsHijackingProtection

func (c *SessionConfig) IsHijackingProtection() bool

IsHijackingProtection returns whether hijacking protection is enabled

func (*SessionConfig) IsLogEnabled

func (c *SessionConfig) IsLogEnabled() bool

IsLogEnabled returns whether logging is enabled

func (*SessionConfig) IsMemory

func (c *SessionConfig) IsMemory() bool

IsMemory returns true if using memory driver

func (*SessionConfig) IsMetricsEnabled

func (c *SessionConfig) IsMetricsEnabled() bool

IsMetricsEnabled returns whether metrics are enabled

func (*SessionConfig) IsMonitoringEnabled

func (c *SessionConfig) IsMonitoringEnabled() bool

IsMonitoringEnabled returns whether monitoring is enabled

func (*SessionConfig) IsRedis

func (c *SessionConfig) IsRedis() bool

IsRedis returns true if using Redis driver

func (*SessionConfig) IsRegenerateOnLogin

func (c *SessionConfig) IsRegenerateOnLogin() bool

IsRegenerateOnLogin returns whether to regenerate session on login

func (*SessionConfig) IsRegenerateOnLogout

func (c *SessionConfig) IsRegenerateOnLogout() bool

IsRegenerateOnLogout returns whether to regenerate session on logout

type StorageConfig

type StorageConfig struct {
	// Driver settings
	Driver string `env:"STORAGE_DRIVER" default:"local" required:"true"`

	// Local storage settings
	LocalPath string `env:"STORAGE_LOCAL_PATH" default:"./storage"`

	// S3 settings
	S3Region         string `env:"S3_REGION" default:"us-east-1"`
	S3Bucket         string `env:"S3_BUCKET" default:""`
	S3AccessKey      string `env:"S3_ACCESS_KEY" default:""`
	S3SecretKey      string `env:"S3_SECRET_KEY" default:""`
	S3Endpoint       string `env:"S3_ENDPOINT" default:""`
	S3PathStyle      bool   `env:"S3_PATH_STYLE" default:"false"`
	S3DisableSSL     bool   `env:"S3_DISABLE_SSL" default:"false"`
	S3ForcePathStyle bool   `env:"S3_FORCE_PATH_STYLE" default:"false"`

	// MinIO settings
	MinIOEndpoint  string `env:"MINIO_ENDPOINT" default:"localhost:9000"`
	MinIOAccessKey string `env:"MINIO_ACCESS_KEY" default:"minioadmin"`
	MinIOSecretKey string `env:"MINIO_SECRET_KEY" default:"minioadmin"`
	MinIOBucket    string `env:"MINIO_BUCKET" default:"mithril"`
	MinIOUseSSL    bool   `env:"MINIO_USE_SSL" default:"false"`
	MinIOPathStyle bool   `env:"MINIO_PATH_STYLE" default:"true"`
	MinIORegion    string `env:"MINIO_REGION" default:"us-east-1"`

	// CDN settings
	CDNURL string `env:"CDN_URL" default:""`

	// File settings
	MaxFileSize     int64    `env:"STORAGE_MAX_FILE_SIZE" default:"10485760"` // 10MB
	AllowedTypes    []string `env:"STORAGE_ALLOWED_TYPES" default:"image/jpeg,image/png,image/gif,application/pdf"`
	DisallowedTypes []string `env:"STORAGE_DISALLOWED_TYPES" default:""`

	// Upload settings
	UploadPath  string `env:"STORAGE_UPLOAD_PATH" default:"uploads"`
	TempPath    string `env:"STORAGE_TEMP_PATH" default:"temp"`
	PublicPath  string `env:"STORAGE_PUBLIC_PATH" default:"public"`
	PrivatePath string `env:"STORAGE_PRIVATE_PATH" default:"private"`

	// Backup settings
	BackupEnabled  bool   `env:"STORAGE_BACKUP_ENABLED" default:"true"`
	BackupPath     string `env:"STORAGE_BACKUP_PATH" default:"./storage/backups"`
	BackupSchedule string `env:"STORAGE_BACKUP_SCHEDULE" default:"0 2 * * *"` // Daily at 2 AM

	// Cleanup settings
	CleanupEnabled       bool          `env:"STORAGE_CLEANUP_ENABLED" default:"true"`
	CleanupSchedule      string        `env:"STORAGE_CLEANUP_SCHEDULE" default:"0 3 * * *"`  // Daily at 3 AM
	CleanupOlderThan     time.Duration `env:"STORAGE_CLEANUP_OLDER_THAN" default:"720h"`     // 30 days
	CleanupTempOlderThan time.Duration `env:"STORAGE_CLEANUP_TEMP_OLDER_THAN" default:"24h"` // 1 day

	// Security settings
	VirusScanEnabled bool   `env:"STORAGE_VIRUS_SCAN_ENABLED" default:"false"`
	VirusScanPath    string `env:"STORAGE_VIRUS_SCAN_PATH" default:"/usr/bin/clamscan"`

	// Encryption settings
	EncryptionEnabled bool   `env:"STORAGE_ENCRYPTION_ENABLED" default:"false"`
	EncryptionKey     string `env:"STORAGE_ENCRYPTION_KEY" default:""`

	// Compression settings
	CompressionEnabled bool `env:"STORAGE_COMPRESSION_ENABLED" default:"false"`

	// Caching settings
	CacheEnabled bool          `env:"STORAGE_CACHE_ENABLED" default:"true"`
	CacheTTL     time.Duration `env:"STORAGE_CACHE_TTL" default:"1h"`

	// Monitoring
	MonitoringEnabled bool   `env:"STORAGE_MONITORING_ENABLED" default:"true"`
	MonitoringPath    string `env:"STORAGE_MONITORING_PATH" default:"/monitor/storage"`

	// Metrics
	MetricsEnabled bool   `env:"STORAGE_METRICS_ENABLED" default:"true"`
	MetricsPath    string `env:"STORAGE_METRICS_PATH" default:"/metrics/storage"`

	// Logging
	LogEnabled bool   `env:"STORAGE_LOG_ENABLED" default:"true"`
	LogLevel   string `env:"STORAGE_LOG_LEVEL" default:"info"`

	// Rate limiting
	RateLimitEnabled bool          `env:"STORAGE_RATE_LIMIT_ENABLED" default:"true"`
	RateLimitRPS     int           `env:"STORAGE_RATE_LIMIT_RPS" default:"10"`
	RateLimitBurst   int           `env:"STORAGE_RATE_LIMIT_BURST" default:"20"`
	RateLimitWindow  time.Duration `env:"STORAGE_RATE_LIMIT_WINDOW" default:"1m"`

	// Health check
	HealthCheckEnabled  bool          `env:"STORAGE_HEALTH_CHECK_ENABLED" default:"true"`
	HealthCheckInterval time.Duration `env:"STORAGE_HEALTH_CHECK_INTERVAL" default:"30s"`
}

StorageConfig holds storage configuration

func (*StorageConfig) GetAllowedTypes

func (c *StorageConfig) GetAllowedTypes() []string

GetAllowedTypes returns the allowed file types

func (*StorageConfig) GetBackupPath

func (c *StorageConfig) GetBackupPath() string

GetBackupPath returns the backup path

func (*StorageConfig) GetBackupSchedule

func (c *StorageConfig) GetBackupSchedule() string

GetBackupSchedule returns the backup schedule

func (*StorageConfig) GetCDNURL

func (c *StorageConfig) GetCDNURL() string

GetCDNURL returns the CDN URL

func (*StorageConfig) GetCacheTTL

func (c *StorageConfig) GetCacheTTL() time.Duration

GetCacheTTL returns the cache TTL

func (*StorageConfig) GetCleanupOlderThan

func (c *StorageConfig) GetCleanupOlderThan() time.Duration

GetCleanupOlderThan returns the cleanup older than duration

func (*StorageConfig) GetCleanupSchedule

func (c *StorageConfig) GetCleanupSchedule() string

GetCleanupSchedule returns the cleanup schedule

func (*StorageConfig) GetCleanupTempOlderThan

func (c *StorageConfig) GetCleanupTempOlderThan() time.Duration

GetCleanupTempOlderThan returns the cleanup temp older than duration

func (*StorageConfig) GetDisallowedTypes

func (c *StorageConfig) GetDisallowedTypes() []string

GetDisallowedTypes returns the disallowed file types

func (*StorageConfig) GetDriver

func (c *StorageConfig) GetDriver() string

GetDriver returns the storage driver

func (*StorageConfig) GetEncryptionKey

func (c *StorageConfig) GetEncryptionKey() string

GetEncryptionKey returns the encryption key

func (*StorageConfig) GetHealthCheckInterval

func (c *StorageConfig) GetHealthCheckInterval() time.Duration

GetHealthCheckInterval returns the health check interval

func (*StorageConfig) GetLocalPath

func (c *StorageConfig) GetLocalPath() string

GetLocalPath returns the local storage path

func (*StorageConfig) GetLogLevel

func (c *StorageConfig) GetLogLevel() string

GetLogLevel returns the log level

func (*StorageConfig) GetMaxFileSize

func (c *StorageConfig) GetMaxFileSize() int64

GetMaxFileSize returns the maximum file size in bytes

func (*StorageConfig) GetMaxFileSizeMB

func (c *StorageConfig) GetMaxFileSizeMB() int64

GetMaxFileSizeMB returns the maximum file size in MB

func (*StorageConfig) GetMetricsPath

func (c *StorageConfig) GetMetricsPath() string

GetMetricsPath returns the metrics path

func (*StorageConfig) GetMinIOAccessKey

func (c *StorageConfig) GetMinIOAccessKey() string

GetMinIOAccessKey returns the MinIO access key

func (*StorageConfig) GetMinIOBucket

func (c *StorageConfig) GetMinIOBucket() string

GetMinIOBucket returns the MinIO bucket name

func (*StorageConfig) GetMinIOEndpoint

func (c *StorageConfig) GetMinIOEndpoint() string

GetMinIOEndpoint returns the MinIO endpoint

func (*StorageConfig) GetMinIORegion

func (c *StorageConfig) GetMinIORegion() string

GetMinIORegion returns the MinIO region

func (*StorageConfig) GetMinIOSecretKey

func (c *StorageConfig) GetMinIOSecretKey() string

GetMinIOSecretKey returns the MinIO secret key

func (*StorageConfig) GetMonitoringPath

func (c *StorageConfig) GetMonitoringPath() string

GetMonitoringPath returns the monitoring path

func (*StorageConfig) GetPrivatePath

func (c *StorageConfig) GetPrivatePath() string

GetPrivatePath returns the private path

func (*StorageConfig) GetPublicPath

func (c *StorageConfig) GetPublicPath() string

GetPublicPath returns the public path

func (*StorageConfig) GetRateLimitBurst

func (c *StorageConfig) GetRateLimitBurst() int

GetRateLimitBurst returns the rate limit burst

func (*StorageConfig) GetRateLimitRPS

func (c *StorageConfig) GetRateLimitRPS() int

GetRateLimitRPS returns the rate limit RPS

func (*StorageConfig) GetRateLimitWindow

func (c *StorageConfig) GetRateLimitWindow() time.Duration

GetRateLimitWindow returns the rate limit window

func (*StorageConfig) GetS3AccessKey

func (c *StorageConfig) GetS3AccessKey() string

GetS3AccessKey returns the S3 access key

func (*StorageConfig) GetS3Bucket

func (c *StorageConfig) GetS3Bucket() string

GetS3Bucket returns the S3 bucket name

func (*StorageConfig) GetS3Endpoint

func (c *StorageConfig) GetS3Endpoint() string

GetS3Endpoint returns the S3 endpoint

func (*StorageConfig) GetS3Region

func (c *StorageConfig) GetS3Region() string

GetS3Region returns the S3 region

func (*StorageConfig) GetS3SecretKey

func (c *StorageConfig) GetS3SecretKey() string

GetS3SecretKey returns the S3 secret key

func (*StorageConfig) GetTempPath

func (c *StorageConfig) GetTempPath() string

GetTempPath returns the temp path

func (*StorageConfig) GetUploadPath

func (c *StorageConfig) GetUploadPath() string

GetUploadPath returns the upload path

func (*StorageConfig) GetVirusScanPath

func (c *StorageConfig) GetVirusScanPath() string

GetVirusScanPath returns the virus scan path

func (*StorageConfig) IsBackupEnabled

func (c *StorageConfig) IsBackupEnabled() bool

IsBackupEnabled returns whether backup is enabled

func (*StorageConfig) IsCacheEnabled

func (c *StorageConfig) IsCacheEnabled() bool

IsCacheEnabled returns whether caching is enabled

func (*StorageConfig) IsCleanupEnabled

func (c *StorageConfig) IsCleanupEnabled() bool

IsCleanupEnabled returns whether cleanup is enabled

func (*StorageConfig) IsCompressionEnabled

func (c *StorageConfig) IsCompressionEnabled() bool

IsCompressionEnabled returns whether compression is enabled

func (*StorageConfig) IsEncryptionEnabled

func (c *StorageConfig) IsEncryptionEnabled() bool

IsEncryptionEnabled returns whether encryption is enabled

func (*StorageConfig) IsHealthCheckEnabled

func (c *StorageConfig) IsHealthCheckEnabled() bool

IsHealthCheckEnabled returns whether health check is enabled

func (*StorageConfig) IsLocal

func (c *StorageConfig) IsLocal() bool

IsLocal returns true if using local driver

func (*StorageConfig) IsLogEnabled

func (c *StorageConfig) IsLogEnabled() bool

IsLogEnabled returns whether logging is enabled

func (*StorageConfig) IsMetricsEnabled

func (c *StorageConfig) IsMetricsEnabled() bool

IsMetricsEnabled returns whether metrics are enabled

func (*StorageConfig) IsMinIO

func (c *StorageConfig) IsMinIO() bool

IsMinIO returns true if using MinIO driver

func (*StorageConfig) IsMinIOPathStyle

func (c *StorageConfig) IsMinIOPathStyle() bool

IsMinIOPathStyle returns whether MinIO path style is enabled

func (*StorageConfig) IsMinIOUseSSL

func (c *StorageConfig) IsMinIOUseSSL() bool

IsMinIOUseSSL returns whether MinIO uses SSL

func (*StorageConfig) IsMonitoringEnabled

func (c *StorageConfig) IsMonitoringEnabled() bool

IsMonitoringEnabled returns whether monitoring is enabled

func (*StorageConfig) IsRateLimitEnabled

func (c *StorageConfig) IsRateLimitEnabled() bool

IsRateLimitEnabled returns whether rate limiting is enabled

func (*StorageConfig) IsS3

func (c *StorageConfig) IsS3() bool

IsS3 returns true if using S3 driver

func (*StorageConfig) IsS3DisableSSL

func (c *StorageConfig) IsS3DisableSSL() bool

IsS3DisableSSL returns whether S3 SSL is disabled

func (*StorageConfig) IsS3ForcePathStyle

func (c *StorageConfig) IsS3ForcePathStyle() bool

IsS3ForcePathStyle returns whether S3 force path style is enabled

func (*StorageConfig) IsS3PathStyle

func (c *StorageConfig) IsS3PathStyle() bool

IsS3PathStyle returns whether S3 path style is enabled

func (*StorageConfig) IsVirusScanEnabled

func (c *StorageConfig) IsVirusScanEnabled() bool

IsVirusScanEnabled returns whether virus scanning is enabled

Jump to

Keyboard shortcuts

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