Documentation
¶
Index ¶
- Constants
- Variables
- func Debug(msg string, fields ...zap.Field)
- func Error(msg string, fields ...zap.Field)
- func GetDb() *gorm.DB
- func GetRedisClient() *goredislib.Client
- func GetRedisSync() *redsync.Redsync
- func GetTraceId(c *gin.Context) (string, bool)
- func GinLogger() gin.HandlerFunc
- func GinRecovery(stack bool) gin.HandlerFunc
- func InitDb()
- func InitLogger(cfg *LogConfig) (err error)
- func InitRedis() error
- func InitSwagger(cfg *SwaggerInfoData, r *gin.Engine)
- func LoadConfig(files ...string) error
- func Log() *zap.Logger
- func SetSwagDoc(docstr string)
- func TDebug(c *gin.Context, msg string, fields ...zap.Field)
- func TError(c *gin.Context, msg string, fields ...zap.Field)
- func TInfo(c *gin.Context, msg string, fields ...zap.Field)
- func TraceIdMiddleware() gin.HandlerFunc
- type ApiResult
- type LogConfig
- type OrmConfig
- type RedisConfig
- type Server
- type ServerConfig
- type SwaggerInfoData
Constants ¶
View Source
const ( TRACE_CTX = "TRACE_CTX" TRACE_ID = "TRACE_ID" )
View Source
const ( DRIVER_MYSQL = "mysql" DRIVER_POSTGRESQL = "pgsql" DRIVER_SQLITE = "sqlite" )
View Source
const DEFAULT_CONFIG_FILENAME = "config"
View Source
const DEFAULT_CONFIG_FILETYPE = "toml"
View Source
const KEY_DEPLOY_ENV = "DEPLOY_ENV"
Variables ¶
View Source
var SwaggerInfo = &SwaggerInfoData{ Enable: false, Version: "", Host: "", BasePath: "", Schemes: []string{}, Title: "", Description: "", }
SwaggerInfo holds exported Swagger Info so clients can modify it
Functions ¶
func GetRedisClient ¶
func GetRedisClient() *goredislib.Client
func GetRedisSync ¶
func GinLogger ¶
func GinLogger() gin.HandlerFunc
func GinRecovery ¶
func GinRecovery(stack bool) gin.HandlerFunc
func InitSwagger ¶
func InitSwagger(cfg *SwaggerInfoData, r *gin.Engine)
func LoadConfig ¶
func SetSwagDoc ¶
func SetSwagDoc(docstr string)
func TraceIdMiddleware ¶
func TraceIdMiddleware() gin.HandlerFunc
Types ¶
type ApiResult ¶
type LogConfig ¶
type LogConfig struct {
Level string `json:"level"`
Filename string `json:"filename"`
MaxSize int `json:"maxsize"`
MaxAge int `json:"max_age"`
MaxBackups int `json:"max_backups"`
}
func GetLogConfig ¶
func GetLogConfig() LogConfig
type OrmConfig ¶
type OrmConfig struct {
Driver string `json:"driver"`
Url string `json:"url"`
Debug bool `json:"debug"`
MaxIdleConns int `json:"maxIdleConns"` // SetMaxIdleConns 用于设置连接池中空闲连接的最大数量。
MaxOpenConns int `json:"maxOpenConns"` // SetMaxOpenConns 设置打开数据库连接的最大数量。
ConnMaxLifetime int `json:"connMaxLifetime"` // SetConnMaxLifetime 设置了连接可复用的最大时间, 秒
}
func GetOrmConfig ¶
func GetOrmConfig() OrmConfig
type RedisConfig ¶
type RedisConfig struct {
Addr string `json:"addr"`
Password string `json:"password"`
Db int `json:"db"`
}
func GetRedisConfig ¶
func GetRedisConfig() RedisConfig
type Server ¶
type Server struct {
Engine *gin.Engine
Cfg *ServerConfig
}
func NewDefaultServer ¶
func NewDefaultServer() *Server
type ServerConfig ¶
type ServerConfig struct {
Host string `json:"host"`
Port int `json:"port"`
Cors bool `json:"cors"`
}
func GetServerConfig ¶
func GetServerConfig() ServerConfig
type SwaggerInfoData ¶
type SwaggerInfoData struct {
Enable bool
Version string
Host string
BasePath string
Schemes []string
Title string
Description string
JsonFile string // json file path
}
func GetSwaggerConfig ¶
func GetSwaggerConfig() SwaggerInfoData
Source Files
¶
Click to show internal directories.
Click to hide internal directories.