config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadLanguages

func LoadLanguages(cfg *Config) ([]string, error)

LoadLanguages loads the supported languages from the config.toml file. Returns at least ["en"] — if the config file is missing or has no languages defined, "en" is used as the primary language.

func LoadPostTypes

func LoadPostTypes(cfg *Config) (*posttype.Service, error)

LoadPostTypes loads custom post types from the config directory If the config file doesn't exist, it returns a service with default post types

func LoadThumbnails

func LoadThumbnails(cfg *Config) (*thumbnail.Service, error)

LoadThumbnails loads thumbnail configurations from the config file (config.toml). If the file does not exist, it returns a service with default configs.

func PrimaryLanguage

func PrimaryLanguage(languages []string) string

PrimaryLanguage returns the first language in the slice, or "en" if empty.

Types

type Config

type Config struct {
	Host               string
	Port               int
	DBPath             string
	DBDriver           string
	DBDSN              string
	DBPoolMaxConns     int
	JWTSecret          string
	LogLevel           string
	SMTPHost           string
	SMTPPort           int
	SMTPUser           string
	SMTPPassword       string
	SMTPFrom           string
	ConfigDir          string
	ConfigFile         string
	CORSAllowedOrigins string
	SiteURL            string
	DevMode            bool
	AdminDevURL        string
	ThemeDir           string

	RateLimitEnabled         bool
	RateLimitAuthPerMinute   int
	RateLimitAPIPerMinute    int
	RateLimitPublicPerMinute int

	AIImageGenerationAPIKey      string
	AIImageGenerationModel       string
	AIImageGenerationSize        string
	AIImageGenerationAspectRatio string

	AITextGenerationAPIKey  string
	AITextGenerationBaseURL string
	AITextGenerationModel   string

	APIKeyPepper string
}

Config holds all application configuration

func Load

func Load() (*Config, error)

Load loads configuration from environment variables It tries to load .env file first, then reads from actual environment

func (*Config) IsImageGenerationEnabled

func (c *Config) IsImageGenerationEnabled() bool

IsImageGenerationEnabled returns true if the Google Imagen API key is configured

func (*Config) IsTextGenerationEnabled

func (c *Config) IsTextGenerationEnabled() bool

IsTextGenerationEnabled returns true if the AI text generation API key is configured

func (*Config) ParseCORSOrigins

func (c *Config) ParseCORSOrigins() []string

ParseCORSOrigins parses the comma-separated CORS origins string into a slice It handles whitespace trimming and validates that each origin has a valid http/https scheme

Jump to

Keyboard shortcuts

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