fix: add mapstructure tags to config structs for proper viper parsing
This commit is contained in:
+24
-24
@@ -8,48 +8,48 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Server ServerConfig
|
Server ServerConfig `mapstructure:"server"`
|
||||||
Database DatabaseConfig
|
Database DatabaseConfig `mapstructure:"database"`
|
||||||
Redis RedisConfig
|
Redis RedisConfig `mapstructure:"redis"`
|
||||||
JWT JWTConfig
|
JWT JWTConfig `mapstructure:"jwt"`
|
||||||
Captcha CaptchaConfig
|
Captcha CaptchaConfig `mapstructure:"captcha"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ServerConfig struct {
|
type ServerConfig struct {
|
||||||
Host string
|
Host string `mapstructure:"host"`
|
||||||
Port int
|
Port int `mapstructure:"port"`
|
||||||
Mode string
|
Mode string `mapstructure:"mode"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DatabaseConfig struct {
|
type DatabaseConfig struct {
|
||||||
Type string // sqlite or mysql
|
Type string `mapstructure:"type"` // sqlite or mysql
|
||||||
Host string
|
Host string `mapstructure:"host"`
|
||||||
Port int
|
Port int `mapstructure:"port"`
|
||||||
User string
|
User string `mapstructure:"user"`
|
||||||
Password string
|
Password string `mapstructure:"password"`
|
||||||
Database string
|
Database string `mapstructure:"database"`
|
||||||
SQLite SQLiteConfig
|
SQLite SQLiteConfig `mapstructure:"sqlite"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SQLiteConfig struct {
|
type SQLiteConfig struct {
|
||||||
Path string
|
Path string `mapstructure:"path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RedisConfig struct {
|
type RedisConfig struct {
|
||||||
Enabled bool
|
Enabled bool `mapstructure:"enabled"`
|
||||||
Host string
|
Host string `mapstructure:"host"`
|
||||||
Port int
|
Port int `mapstructure:"port"`
|
||||||
Password string
|
Password string `mapstructure:"password"`
|
||||||
DB int
|
DB int `mapstructure:"db"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type JWTConfig struct {
|
type JWTConfig struct {
|
||||||
Secret string
|
Secret string `mapstructure:"secret"`
|
||||||
ExpireTime int // hours
|
ExpireTime int `mapstructure:"expire_time"` // hours
|
||||||
}
|
}
|
||||||
|
|
||||||
type CaptchaConfig struct {
|
type CaptchaConfig struct {
|
||||||
ModelPath string
|
ModelPath string `mapstructure:"model_path"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var Cfg *Config
|
var Cfg *Config
|
||||||
|
|||||||
Reference in New Issue
Block a user