Documentation ¶
Index ¶
- Variables
- func InitBaseRouter(router *gin.Engine) *gin.Engine
- func InitGormPg() *gorm.DB
- func InitRedis() *redis.Client
- func InitServer(address string, router *gin.Engine) server
- func InitServerConfig()
- func InitSwagger(router *gin.Engine, staticPath string) *gin.Engine
- type PgConn
- type Redis
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var ( O_SERVER_CONFIG *ServerConfig O_DB_PG *gorm.DB O_REDIS *redis.Client )
singleton
Functions ¶
func InitGormPg ¶
GormPgSql 初始化 Postgresql 数据库 Author [piexlmax](https://github.com/piexlmax) Author [SliverHorn](https://github.com/SliverHorn)
func InitServer ¶
func InitServerConfig ¶
func InitServerConfig()
Types ¶
type PgConn ¶
type PgConn struct { DSN string `mapstructure:"dsn" json:"dsn" yaml:"dsn"` // 是否开启Gorm全局日志 MaxIdleConns int `mapstructure:"max-idle-conns" json:"max-idle-conns" yaml:"max-idle-conns"` // 空闲中的最大连接数 MaxOpenConns int `mapstructure:"max-open-conns" json:"max-open-conns" yaml:"max-open-conns"` // 打开到数据库的最大连接数 SlowThreshold int `mapstructure:"slow-threshold" json:"slow-threshold" yaml:"slow-threshold"` // slow sql threshold }
func (PgConn) GormPgSqlByConfig ¶
GormPgSqlByConfig 初始化 Postgresql 数据库 通过参数
type Redis ¶
type Redis struct { Addr string `mapstructure:"addr" json:"addr" yaml:"addr"` // 服务器地址:端口 Username string `mapstructure:"username" json:"username" yaml:"username"` // 密码 Password string `mapstructure:"password" json:"password" yaml:"password"` // 密码 DB int `mapstructure:"db" json:"db" yaml:"db"` // redis的哪个数据库 }
func (Redis) InitRedisByConfig ¶
func (redisCfg Redis) InitRedisByConfig() *redis.Client
type ServerConfig ¶
type ServerConfig struct { Redis Redis `mapstructure:"redis" json:"redis" yaml:"redis"` PgConn PgConn `mapstructure:"pg-conn" json:"pg-conn" yaml:"pg-conn"` ServerName string `mapstructure:"server-name" json:"server-name" yaml:"server-name"` LogPath string `mapstructure:"log-path" json:"log-path" yaml:"log-path"` TimeOut int `mapstructure:"time-out" json:"time-out" yaml:"time-out"` SecurityKey string `mapstructure:"security-key" json:"security-key" yaml:"security-key"` SecurityValue string `mapstructure:"security-value" json:"security-value" yaml:"security-value"` }
func LoadServerConfig ¶
func LoadServerConfig(serverConfig *ServerConfig) *ServerConfig
Click to show internal directories.
Click to hide internal directories.