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 {
|
||||
Server ServerConfig
|
||||
Database DatabaseConfig
|
||||
Redis RedisConfig
|
||||
JWT JWTConfig
|
||||
Captcha CaptchaConfig
|
||||
Server ServerConfig `mapstructure:"server"`
|
||||
Database DatabaseConfig `mapstructure:"database"`
|
||||
Redis RedisConfig `mapstructure:"redis"`
|
||||
JWT JWTConfig `mapstructure:"jwt"`
|
||||
Captcha CaptchaConfig `mapstructure:"captcha"`
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
Host string
|
||||
Port int
|
||||
Mode string
|
||||
Host string `mapstructure:"host"`
|
||||
Port int `mapstructure:"port"`
|
||||
Mode string `mapstructure:"mode"`
|
||||
}
|
||||
|
||||
type DatabaseConfig struct {
|
||||
Type string // sqlite or mysql
|
||||
Host string
|
||||
Port int
|
||||
User string
|
||||
Password string
|
||||
Database string
|
||||
SQLite SQLiteConfig
|
||||
Type string `mapstructure:"type"` // sqlite or mysql
|
||||
Host string `mapstructure:"host"`
|
||||
Port int `mapstructure:"port"`
|
||||
User string `mapstructure:"user"`
|
||||
Password string `mapstructure:"password"`
|
||||
Database string `mapstructure:"database"`
|
||||
SQLite SQLiteConfig `mapstructure:"sqlite"`
|
||||
}
|
||||
|
||||
type SQLiteConfig struct {
|
||||
Path string
|
||||
Path string `mapstructure:"path"`
|
||||
}
|
||||
|
||||
type RedisConfig struct {
|
||||
Enabled bool
|
||||
Host string
|
||||
Port int
|
||||
Password string
|
||||
DB int
|
||||
Enabled bool `mapstructure:"enabled"`
|
||||
Host string `mapstructure:"host"`
|
||||
Port int `mapstructure:"port"`
|
||||
Password string `mapstructure:"password"`
|
||||
DB int `mapstructure:"db"`
|
||||
}
|
||||
|
||||
type JWTConfig struct {
|
||||
Secret string
|
||||
ExpireTime int // hours
|
||||
Secret string `mapstructure:"secret"`
|
||||
ExpireTime int `mapstructure:"expire_time"` // hours
|
||||
}
|
||||
|
||||
type CaptchaConfig struct {
|
||||
ModelPath string
|
||||
ModelPath string `mapstructure:"model_path"`
|
||||
}
|
||||
|
||||
var Cfg *Config
|
||||
|
||||
Reference in New Issue
Block a user