39 lines
1.3 KiB
Go
39 lines
1.3 KiB
Go
type Config struct {
|
|
DB struct {
|
|
Type string `ini:"DBTYPE"`
|
|
Host string `ini:"DBHOST"`
|
|
Port int `ini:"DBPORT"`
|
|
User string `ini:"DBUSER"`
|
|
Password string `ini:"DBPASS"`
|
|
Name string `ini:"DBNAME"`
|
|
} `ini:"db"`
|
|
Server struct {
|
|
Host string `ini:"SERVERHOST"`
|
|
AllowOrigin string `ini:"ALLOWORIGIN"`
|
|
} `ini:"server"`
|
|
Security struct {
|
|
AISpamProtection bool `ini:"AI_SPAM_PROTECTION"`
|
|
AIProvider string `ini:"AI_PROVIDER"`
|
|
AIEndpoint string `ini:"AI_ENDPOINT"`
|
|
AIAPIKey string `ini:"AI_APIKEY"`
|
|
AISecretKey string `ini:"AI_SECRETKEY"`
|
|
AIModel string `ini:"AI_MODEL"`
|
|
AIInstructions string `ini:"AI_INSTURCTIONS"`
|
|
CaptchaEnabled bool `ini:"CAPTCHA_ENABLED"`
|
|
CaptchaType string `ini:"CAPTCHA_TYPE"`
|
|
CaptchaSiteKey string `ini:"CAPTCHA_SITEKEY"`
|
|
CaptchaSecretKey string `ini:"CAPTCHA_SECRETKEY"`
|
|
} `ini:"security"`
|
|
}
|
|
|
|
import "gopkg.in/ini.v1"
|
|
|
|
func LoadConfig(filePath string) (*Config, error) {
|
|
cfg, err := ini.Load(filePath)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
config := &Config{}
|
|
err = cfg.MapTo(config)
|
|
return config, err
|
|
} |