Documentation
¶
Index ¶
- Variables
- type CORS
- type Captcha
- type Config
- func (c *Config) CORS() *CORS
- func (c *Config) CaptchaConf() *Captcha
- func (c *Config) CloseDB() error
- func (c *Config) DB() *gorm.DB
- func (c *Config) DaemonLogFile() string
- func (c *Config) DaemonPidFile() string
- func (c *Config) DatabaseDSN() string
- func (c *Config) Debug() bool
- func (c *Config) HttpServerHost() string
- func (c *Config) HttpServerMode() string
- func (c *Config) HttpServerPort() uint16
- func (c *Config) InitDB(ctx context.Context) error
- func (c *Config) JWTConf() *JWT
- func (c *Config) RedisConf() *Redis
- func (c *Config) ShouldDaemonize() bool
- func (c *Config) ShutDown()
- func (c *Config) StaticPath() string
- func (c *Config) SuperAdmin() *SpAdmin
- type JWT
- type Params
- type Redis
- type SpAdmin
Constants ¶
This section is empty.
Variables ¶
var GlobalFlags = []cli.Flag{ cli.BoolFlag{ Name: "debug", Usage: "run in debug mode", EnvVar: "CENTAUR_DEBUG", }, cli.StringFlag{ Name: "log-level", Usage: "specify log level, value is one of [trace, debug, info, warning, error, fatal or panic]", Value: "info", EnvVar: "CENTAUR_LOG_LEVEL", }, cli.StringFlag{ Name: "config-file, c", Usage: "load configuration from `FILENAME`", Value: "./centaur.yml", EnvVar: "CENTAUR_CONFIG_FILE", }, cli.StringFlag{ Name: "http-host, h", Usage: "HTTP server host", Value: "", EnvVar: "CENTAUR_HTTP_HOST", }, cli.StringFlag{ Name: "http-port, p", Usage: "HTTp server port", Value: "80", EnvVar: "CENTAUR_HTTP_PORT", }, cli.StringFlag{ Name: "mysql-host", Usage: "MySQL server host", Value: "", EnvVar: "CENTAUR_MYSQL_HOST", }, cli.StringFlag{ Name: "mysql-port", Usage: "MySQL server host", Value: "3306", EnvVar: "CENTAUR_MYSQL_HOST", }, cli.BoolFlag{ Name: "daemonize, d", Usage: "run centaur as Daemon", EnvVar: "CENTAUR_DAEMON_MODE", }, }
GlobalFlags are Global CLI Flags
Functions ¶
This section is empty.
Types ¶
type CORS ¶
type CORS struct {
CORSEnable bool `yaml:"cors-enable"`
AllowOrigins []string `yaml:"allow-origins"`
AllowMethods []string `yaml:"allow-methods"`
AllowHeaders []string `yaml:"allow-headers"`
AllowCredentials bool `yaml:"allow-credentials"`
MaxAge int `yaml:"max-age"`
}
CORS 描述跨域请求配置
type Captcha ¶
type Captcha struct {
Length int `yaml:"length"`
Width int `yaml:"width"`
Height int `yaml:"height"`
RedisPrefix string `yaml:"redis_prefix"`
}
Captcha 指定验证码配置,包括验证码位数/高度/宽度/验证码的redis前缀等
type Config ¶
type Config struct {
// contains filtered or unexported fields
}
func GetGlobalConfig ¶
func GetGlobalConfig() *Config
func (*Config) CaptchaConf ¶
CaptchaConf returns Login Captcha config
func (*Config) DaemonLogFile ¶
DaemonLogFile will return log output file at daemon mode
func (*Config) DaemonPidFile ¶
DaemonPidFile will return pid file at daemon mode
func (*Config) DatabaseDSN ¶
DatabaseDSN will return the connect string of database
func (*Config) HttpServerHost ¶
HttpServerHost will return the host ip which is listening for new connections.
func (*Config) HttpServerMode ¶
HttpServerMode will return under which mode server will be running.
func (*Config) HttpServerPort ¶
HttpServerPort will return HTTP Server's using port.
func (*Config) ShouldDaemonize ¶
ShouldDaemonize will return true if daemon mode is set.
func (*Config) ShutDown ¶
func (c *Config) ShutDown()
ShutDown will release the using resources. inlcuding DB connection, ...
func (*Config) StaticPath ¶
StaticPath will return where are static files stored.
func (*Config) SuperAdmin ¶
SuperAdmin returns User who owns root permission
type Params ¶
type Params struct {
Name string
Version string
Debug bool `yaml:"debug" flag:"debug"`
LogLevel string `yaml:"log-level" flag:"log-level"`
ConfigFile string
ConfigPath string `yaml:"config-path" flag:"config-path"`
DbType string `yaml:"db-type" flag:"db-type"`
DbServerHost string `yaml:"db-host" flag:"db-host"`
DbServerPort uint16 `yaml:"db-port" flag:"db-port"`
DbUserName string `yaml:"db-user" flag:"db-user"`
DbPassword string `yaml:"db-password" flag:"db-password"`
DbName string `yaml:"db-name" flag:"db-name"`
HttpServerHost string `yaml:"http-host" flag:"http-host"`
HttpServerPort uint16 `yaml:"http-port" flag:"http-port"`
HttpServerMode string `yaml:"http-server-mode" flag:"http-server-mode"`
DaemonMode bool `yaml:"daemon" flag:"daemon"`
DaemonPidPath string `yaml:"daemon-pid-path" flag:"daemon-pid-path"`
DaemonLogPath string `yaml:"daemon-log-path" flag:"daemon-log-path"`
StaticPath string `yaml:"static-path" flag:"static-path"`
CORS *CORS `yaml:"cors"`
RedisConf *Redis `yaml:"redis"`
CaptchaConf *Captcha `yaml:"captcha"`
SuperAdmin *SpAdmin `yaml:"superadmin"`
JWTConf *JWT `yaml:"jwt"`
}
Params stores the application config
func (*Params) LoadFromFile ¶
LoadFromFile will read config from config file and parse it into *Params