Documentation ¶
Index ¶
- Variables
- func GetIP() string
- func GetIPWithDefault(defaultIP string) string
- func GetPort() int
- func GetPortWithDefault(defaultPort int) int
- func GetTokenAccessDuration() time.Duration
- func GetTokenRefreshDuration() time.Duration
- func GetTokenSymmetricKey() string
- func GetVersion() string
- func Init()
- func InitWithPathAndType(configPath, configType string)
- func IsDebugMode() bool
- func SetEnv(e TypeEnv)
- type Config
- type TypeEnv
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Set = viper.Set Get = viper.Get GetString = viper.GetString GetInt = viper.GetInt GetBool = viper.GetBool GetFloat64 = viper.GetFloat64 GetDuration = viper.GetDuration )
Functions ¶
func GetIPWithDefault ¶
GetIPWithDefault returns the listen IP of the HTTP server. If the IP is not set, it returns the default IP.
func GetPortWithDefault ¶
GetPortWithDefault returns the port of the HTTP server. If the port is not set, it returns the default port.
func GetTokenAccessDuration ¶
GetTokenAccessDuration returns the duration of the access token.
func GetTokenRefreshDuration ¶
GetTokenRefreshDuration returns the duration of the refresh token.
func GetTokenSymmetricKey ¶
func GetTokenSymmetricKey() string
GetTokenSymmetricKey returns the symmetric key of the token.
func InitWithPathAndType ¶
func InitWithPathAndType(configPath, configType string)
func IsDebugMode ¶
func IsDebugMode() bool
IsDebugMode returns whether the application is in debug mode.
Types ¶
type Config ¶
type Config struct { Version string `mapstructure:"version"` DebugMode bool `mapstructure:"debug_mode"` HTTPServer struct { IP string `mapstructure:"ip"` Port int `mapstructure:"port"` } `mapstructure:"http_server"` Token struct { SymmetricKey string `mapstructure:"symmetric_key"` AccessDuration time.Duration `mapstructure:"access_duration"` RefreshDuration time.Duration `mapstructure:"refresh_duration"` } `mapstructure:"token"` MySQL struct { Log bool `mapstructure:"log"` MaxOpenConnections int `mapstructure:"max_open_connections"` MaxIdleConnections int `mapstructure:"max_idle_connections"` MaxLifetimeDuration time.Duration `mapstructure:"max_lifetime_duration"` Read struct { Addr string `mapstructure:"addr"` User string `mapstructure:"user"` Password string `mapstructure:"password"` Name string `mapstructure:"name"` } `mapstructure:"read"` Write struct { Addr string `mapstructure:"addr"` User string `mapstructure:"user"` Password string `mapstructure:"password"` Name string `mapstructure:"name"` } `mapstructure:"write"` } `mapstructure:"mysql"` }
Config stores configuration of the application. The values are read by viper from a config file or environment variables.
Click to show internal directories.
Click to hide internal directories.