middleware

package
v0.0.0-...-5357738 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JWTAuth

func JWTAuth() gin.HandlerFunc

JWTAuth jwt认证函数

func RecoveryMiddleware

func RecoveryMiddleware() gin.HandlerFunc

RecoveryMiddleware RecoveryMiddleware捕获所有panic,并且返回错误信息

func RequestInLog

func RequestInLog(c *gin.Context)

请求进入日志

func RequestLog

func RequestLog() gin.HandlerFunc

func RequestOutLog

func RequestOutLog(c *gin.Context)

请求输出日志

func ResponseError

func ResponseError(c *gin.Context, err error)

func ResponseSuccess

func ResponseSuccess(c *gin.Context, data interface{})

func TranslationMiddleware

func TranslationMiddleware() gin.HandlerFunc

设置Translation

Types

type Response

type Response struct {
	ErrorCode ResponseCode `json:"errno"`
	ErrorMsg  string       `json:"errmsg"`
	RealErr   string       `json:"real_err"`
	Data      interface{}  `json:"data"`
	TraceId   interface{}  `json:"trace_id"`
	Stack     interface{}  `json:"stack"`
}

type ResponseCode

type ResponseCode int
const (
	SuccessCode ResponseCode = iota
)

1000以下为通用码,1000以上为用户自定义码

Jump to

Keyboard shortcuts

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