Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SaveConfig ¶
SaveConfig writes the provided Config struct to a YAML file.
Types ¶
type CORSConfig ¶
type CORSConfig struct {
AllowedOrigins []string `mapstructure:"allowed_origins" yaml:"allowed_origins"`
AllowedMethods []string `mapstructure:"allowed_methods" yaml:"allowed_methods"`
AllowedHeaders []string `mapstructure:"allowed_headers" yaml:"allowed_headers"`
AllowCredentials bool `mapstructure:"allow_credentials" yaml:"allow_credentials"`
MaxAge int `mapstructure:"max_age" yaml:"max_age"`
}
type Config ¶
type Config struct {
LogLevel string `mapstructure:"log_level"`
Mode string `mapstructure:"mode" yaml:"mode"` // Gin mode: development | production | test
TelemetryEnabled bool `mapstructure:"telemetry_enabled"`
JWTSecret string `mapstructure:"jwt_secret"`
DatabaseURL string `mapstructure:"database_url"`
ServerPort string `mapstructure:"server_port"`
MinPasswordLength int `json:"min_password_length" yaml:"min_password_length"`
// Redis settings
Redis RedisConfig `mapstructure:"redis"`
// CORS settings
CORS CORSConfig `mapstructure:"cors"`
// LLM settings
LLM LLMConfig `mapstructure:"llm" yaml:"llm"`
// Rate limiting for /auth/* (shared across replicas through Redis)
RateLimit RateLimitConfig `mapstructure:"rate_limit" yaml:"rate_limit"`
// TrustedProxies lists the proxies (IPs or CIDRs) whose X-Forwarded-For
// header is trusted to find the client IP. Empty: use the TCP peer.
TrustedProxies []string `mapstructure:"trusted_proxies" yaml:"trusted_proxies"`
// Media uploads and storage
Media MediaConfig `mapstructure:"media" yaml:"media"`
}
Config holds all application settings.
func LoadConfig ¶
LoadConfig loads the configuration from file and environment variables.
func LoadTestConfig ¶
LoadTestConfig loads a test configuration file.
func (Config) RedisClientOpt ¶
func (c Config) RedisClientOpt() asynq.RedisClientOpt
RedisClientOpt returns the asynq connection options for the configured Redis, including password and database index.
func (Config) RedisOptions ¶
RedisOptions returns go-redis options for the configured Redis.
type LLMConfig ¶
type LLMConfig struct {
Provider string `mapstructure:"provider" yaml:"provider"`
Model string `mapstructure:"model" yaml:"model"`
APIKey string `mapstructure:"api_key" yaml:"api_key"`
APISecret string `mapstructure:"api_secret" yaml:"api_secret"`
BaseURL string `mapstructure:"base_url" yaml:"base_url"` // optional API endpoint override
}
LLMConfig holds settings for Large Language Model providers.
type MediaConfig ¶ added in v0.4.0
type MediaConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
Driver string `mapstructure:"driver" yaml:"driver"` // local | s3
MaxSizeMB int `mapstructure:"max_size_mb" yaml:"max_size_mb"`
AllowedTypes []string `mapstructure:"allowed_types" yaml:"allowed_types"` // MIME patterns; empty = built-in list
// PublicURL is the base URL files are downloaded from (CDN, public
// bucket, or the API's /uploads). Empty: /uploads on the API for local
// files, presigned URLs for S3.
PublicURL string `mapstructure:"public_url" yaml:"public_url"`
Local MediaLocalConfig `mapstructure:"local" yaml:"local"`
S3 MediaS3Config `mapstructure:"s3" yaml:"s3"`
}
MediaConfig configures uploads (POST /api/media) and where files are stored.
type MediaLocalConfig ¶ added in v0.4.0
type MediaLocalConfig struct {
Path string `mapstructure:"path" yaml:"path"`
}
MediaLocalConfig configures the filesystem media driver.
type MediaS3Config ¶ added in v0.4.0
type MediaS3Config struct {
Endpoint string `mapstructure:"endpoint" yaml:"endpoint"`
Region string `mapstructure:"region" yaml:"region"`
Bucket string `mapstructure:"bucket" yaml:"bucket"`
AccessKey string `mapstructure:"access_key" yaml:"access_key"`
SecretKey string `mapstructure:"secret_key" yaml:"secret_key"`
UseSSL bool `mapstructure:"use_ssl" yaml:"use_ssl"`
PathStyle bool `mapstructure:"path_style" yaml:"path_style"`
Prefix string `mapstructure:"prefix" yaml:"prefix"`
PresignExpiry time.Duration `mapstructure:"presign_expiry" yaml:"presign_expiry"`
}
MediaS3Config configures the S3-compatible media driver.
type RateLimitConfig ¶
type RateLimitConfig struct {
Enabled bool `mapstructure:"enabled" yaml:"enabled"`
// AuthPerMinute is the number of /auth/* requests allowed per client IP
// per minute (0 disables it).
AuthPerMinute int `mapstructure:"auth_per_minute" yaml:"auth_per_minute"`
// LoginFailures is the number of failed logins allowed per username and
// client IP within LoginWindow before further attempts get 429.
LoginFailures int `mapstructure:"login_failures" yaml:"login_failures"`
LoginWindow time.Duration `mapstructure:"login_window" yaml:"login_window"`
}
RateLimitConfig protects the authentication endpoints.
type RedisConfig ¶
type RedisConfig struct {
Address string `mapstructure:"address" yaml:"address"`
Password string `mapstructure:"password" yaml:"password"`
DB int `mapstructure:"db" yaml:"db"`
}
RedisConfig holds settings for the Redis connection.