middleware

package
v0.0.0-...-cda82d8 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	JoySuccess     = NewJoyError(http.StatusOK, global.SUCCESS, "success")
	JoyServerError = NewJoyError(http.StatusInternalServerError, global.ServiceError, "系统异常,请稍后重试!")
	JoyNotFound    = NewJoyError(http.StatusNotFound, global.NotFound, http.StatusText(http.StatusNotFound))
)

Functions

func Cors

func Cors() gin.HandlerFunc

处理跨域请求,支持options访问

func ErrHandler

func ErrHandler() gin.HandlerFunc

func GinLogger

func GinLogger() gin.HandlerFunc

GinLogger gin定制logger

func HandleNotFound

func HandleNotFound(c *gin.Context)

404处理

func LoadTls

func LoadTls() gin.HandlerFunc

Types

type GormLogger

type GormLogger struct {
	SlowThreshold time.Duration
	Colorful      bool
	LogLevel      glogger.LogLevel
	// contains filtered or unexported fields
}

func (*GormLogger) Error

func (g *GormLogger) Error(ctx context.Context, message string, data ...interface{})

func (*GormLogger) Info

func (g *GormLogger) Info(ctx context.Context, message string, data ...interface{})

func (*GormLogger) LogMode

func (g *GormLogger) LogMode(level glogger.LogLevel) glogger.Interface

func (*GormLogger) Printf

func (g *GormLogger) Printf(message string, data ...interface{})

func (*GormLogger) Trace

func (g *GormLogger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error)

func (*GormLogger) Warn

func (g *GormLogger) Warn(ctx context.Context, message string, data ...interface{})

type JoyError

type JoyError struct {
	StatusCode int    `json:"-"`
	Code       int    `json:"code"`
	Msg        string `json:"msg"`
}

错误处理的结构体

func JoyOtherError

func JoyOtherError(message string) *JoyError

func NewJoyError

func NewJoyError(statusCode, Code int, msg string) *JoyError

func (*JoyError) Error

func (e *JoyError) Error() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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