web

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 28, 2023 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetJwtToken

func GetJwtToken(c *gin.Context, authKey string) string

func GetRequestIP

func GetRequestIP(c *gin.Context) string

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后返回自定义的消息包

func UIntParam

func UIntParam(c *gin.Context, paramName string) (uint64, error)

UIntParam 得到Uint64类型的参数

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

type GinServer struct {
	Engine *gin.Engine
	// contains filtered or unexported fields
}

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) RunAsync

func (instance *GinServer) RunAsync()

RunAsync 异步方式启动

func (*GinServer) Shutdown

func (instance *GinServer) Shutdown()

Shutdown 优雅关闭WebServer

func (*GinServer) WaitInterrupt

func (instance *GinServer) WaitInterrupt()

WaitInterrupt 等待接受中断信号 1、停止接收新请求,等待已有请求执行完毕; 2、如果等待时间超过ShutdownTimeout设定的时间,则强制关闭HttpServer

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL