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 NewMongo(c *Config, l *zap.Logger) *mongo.Database
- func NewMysql(c *Config, l *zap.Logger) *gorm.DB
- func NewRedis(c *Config) redis.Cmdable
- func NewServer(middlewares []gin.HandlerFunc, uh *handler.UserHandler, ...) *gin.Engine
- func NewViper() *viper.Viper
- func NewZap(c *Config) *zap.Logger
- type CacheConfig
- type Config
- type LimitConfig
- type MongoConfig
- type MysqlConfig
- type RedisConfig
- type Server
- type ServerConfig
- type SmsLimitConfig
- type TokenConfig
- 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, ah *handler.ArticleHandler) *gin.Engine
NewServer 创建server
Types ¶
type CacheConfig ¶
type CacheConfig struct {
UserExpiration int64 `mapstructure:"user-expiration" json:"user-expiration" yaml:"user-expiration"`
}
type Config ¶
type Config struct { ServerConfig *ServerConfig `mapstructure:"server" json:"server" yaml:"server"` ZapConfig *ZapConfig `mapstructure:"zap" json:"zap" yaml:"zap"` MysqlConfig *MysqlConfig `mapstructure:"mysql" json:"mysql" yaml:"mysql"` MongoConfig *MongoConfig `mapstructure:"mongo" json:"mongo" yaml:"mongo"` RedisConfig *RedisConfig `mapstructure:"redis" json:"redis" yaml:"redis"` TokenConfig *TokenConfig `mapstructure:"token" json:"token" yaml:"token"` CacheConfig *CacheConfig `mapstructure:"cache" json:"cache" yaml:"cache"` LimitConfig *LimitConfig `mapstructure:"limit" json:"limit" yaml:"limit"` }
Config 配置文件
type LimitConfig ¶
type LimitConfig struct {
SmsLimitConfig *SmsLimitConfig `mapstructure:"sms" json:"sms" yaml:"sms"`
}
type MongoConfig ¶
type MongoConfig struct { Hostname string `mapstructure:"hostname" json:"hostname" yaml:"hostname"` // 服务器地址 Port int `mapstructure:"port" json:"port" yaml:"port"` // 端口 Database string `mapstructure:"database" json:"database" yaml:"database"` // 数据库名 Username string `mapstructure:"username" json:"username" yaml:"username"` // 数据库用户名 Password string `mapstructure:"password" json:"password" yaml:"password"` // 数据库密码 }
MongoConfig mongodb配置
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 SmsLimitConfig ¶
type TokenConfig ¶
type TokenConfig struct {
Expiration int `mapstructure:"expiration" json:"expiration" yaml:"expiration"`
}
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.