Documentation ¶
Index ¶
- func GetJwtToken(c *gin.Context, authKey string) string
- func GetRequestIP(c *gin.Context) string
- func GinZapLog(logger *zap.Logger, runMode string) gin.HandlerFunc
- func IgnoreIndexAndFavicon() gin.HandlerFunc
- func RecoveryWithZap(logger *zap.Logger, stack bool) gin.HandlerFunc
- func UIntParam(c *gin.Context, paramName string) (uint64, error)
- type Config
- type GinServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetRequestIP ¶
func GinZapLog ¶
func GinZapLog(logger *zap.Logger, runMode string) gin.HandlerFunc
GinZapLog 用zap包记录日志,可打印post请求form及响应内容
func IgnoreIndexAndFavicon ¶
func IgnoreIndexAndFavicon() gin.HandlerFunc
IgnoreIndexAndFavicon 忽略index和favicon.ico请求
func RecoveryWithZap ¶
func RecoveryWithZap(logger *zap.Logger, stack bool) gin.HandlerFunc
RecoveryWithZap 拦截处理请求的goroute中发生的panic copy了gin_zap包的代码,修改了painc后返回自定义的消息包
Types ¶
type Config ¶
type Config struct { RunMode string `yaml:"runMode"` // 启动模式:debug|release|test Port int `yaml:"port"` // 服务器端口 ShutdownTimeout int `yaml:"shutdownTimeout"` // 优雅停止服务的超时时间(秒) }
Config web server config
type GinServer ¶
func NewGinServer ¶
func NewGinServer(conf Config, log *zap.SugaredLogger) *GinServer
func (*GinServer) RouteGroup ¶
func (instance *GinServer) RouteGroup(relativePath string, middlewares ...gin.HandlerFunc) *gin.RouterGroup
RouteGroup 增加组路由
func (*GinServer) WaitInterrupt ¶
func (instance *GinServer) WaitInterrupt()
WaitInterrupt 等待接受中断信号 1、停止接收新请求,等待已有请求执行完毕; 2、如果等待时间超过ShutdownTimeout设定的时间,则强制关闭HttpServer
Click to show internal directories.
Click to hide internal directories.