Documentation
¶
Index ¶
- Variables
- func CorsMiddleware() gin.HandlerFunc
- func LoggerMiddleware(l *zap.Logger) gin.HandlerFunc
- func LoginMiddleWare() gin.HandlerFunc
- func NewMiddlewares(l *zap.Logger) []gin.HandlerFunc
- func NewMysql(config *Config) *gorm.DB
- func NewRedis(config *Config) redis.Cmdable
- func NewServer(middlewares []gin.HandlerFunc, uh *handler.UserHandler, ...) *gin.Engine
- func NewViper() *viper.Viper
- func NewWebSocketManager(config *Config) map[string]*websocket.Manager
- func NewZap(config *Config) *zap.Logger
- type Config
- type MysqlConfig
- type RedisConfig
- type ServerConfig
- type WebSocketConfig
- type ZapConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var FileRotateLogs = new(fileRotateLogs)
Functions ¶
func NewMiddlewares ¶
func NewMiddlewares(l *zap.Logger) []gin.HandlerFunc
func NewServer ¶
func NewServer(middlewares []gin.HandlerFunc, uh *handler.UserHandler, wh *handler.WebSocketHandler) *gin.Engine
Types ¶
type Config ¶
type Config struct { ServerConfig *ServerConfig `mapstructure:"server" json:"server" yaml:"server"` MysqlConfig *MysqlConfig `mapstructure:"mysql" json:"mysql" yaml:"mysql"` RedisConfig *RedisConfig `mapstructure:"redis" json:"redis" yaml:"redis"` ZapConfig *ZapConfig `mapstructure:"zap" json:"zap" yaml:"zap"` WebSocketConfig *WebSocketConfig `mapstructure:"websocket" json:"websocket" yaml:"websocket"` }
Config 配置文件
type MysqlConfig ¶
type MysqlConfig struct { Hostname string `mapstructure:"hostname" json:"hostname" yaml:"hostname"` // 服务器地址 Port int `mapstructure:"port" json:"port" yaml:"port"` // 端口 Config string `mapstructure:"config" json:"config" yaml:"config"` // 高级配置 Database string `mapstructure:"database" json:"database" yaml:"database"` // 数据库名 Username string `mapstructure:"username" json:"username" yaml:"username"` // 数据库用户名 Password string `mapstructure:"password" json:"password" yaml:"password"` // 数据库密码 }
MysqlConfig mysql配置
type RedisConfig ¶
type ServerConfig ¶
type ServerConfig struct { Host string `mapstructure:"host" json:"host" yaml:"host"` Port int `mapstructure:"port" json:"port" yaml:"port"` }
ServerConfig server配置
type WebSocketConfig ¶
type WebSocketConfig struct {
Biz []string `mapstructure:"biz" json:"biz" yaml:"biz"`
}
WebSocketConfig websocket配置
type ZapConfig ¶
type ZapConfig struct { Level string `mapstructure:"level" json:"level" yaml:"level"` // 级别 Prefix string `mapstructure:"prefix" json:"prefix" yaml:"prefix"` // 日志前缀 Format string `mapstructure:"format" json:"format" yaml:"format"` // 输出 Director string `mapstructure:"director" json:"director" yaml:"director"` // 日志文件夹 EncodeLevel string `mapstructure:"encode-level" json:"encode-level" yaml:"encode-level"` // 编码级 StacktraceKey string `mapstructure:"stacktrace-key" json:"stacktrace-key" yaml:"stacktrace-key"` // 栈名 MaxAge int `mapstructure:"max-age" json:"max-age" yaml:"max-age"` // 日志留存时间 ShowLine bool `mapstructure:"show-line" json:"show-line" yaml:"show-line"` // 显示行 LogInConsole bool `mapstructure:"log-in-console" json:"log-in-console" yaml:"log-in-console"` // 输出控制台 }
ZapConfig 配置
Click to show internal directories.
Click to hide internal directories.