api

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RespMiddleWareDisabled = "RespMiddleWareDisabled"

	ReqError  = "error"
	ReqResult = "result"
)
View Source
const (
	Address    = "address"
	Signature  = "signature"
	DeviceName = "deviceName"
	DeviceType = "deviceType"
	Uuid       = "uuid"
	Version    = "version"
)
View Source
const HeaderTimeOut = 120 * time.Second

Variables

View Source
var Chat33GinLogFormatter = func(param gin.LogFormatterParams) string {
	var statusColor, methodColor, resetColor string
	if param.IsOutputColor() {
		statusColor = param.StatusCodeColor()
		methodColor = param.MethodColor()
		resetColor = param.ResetColor()
	}

	if param.Latency > time.Minute {

		param.Latency = param.Latency - param.Latency%time.Second
	}
	return fmt.Sprintf("[GIN] %v |%s %3d %s| %13v | %15s |%s %-7s %s %s\n%s",
		param.TimeStamp.Format("2006/01/02 - 15:04:05"),
		statusColor, param.StatusCode, resetColor,
		param.Latency,
		param.ClientIP,
		methodColor, param.Method, resetColor,
		param.Path,

		param.ErrorMessage,
	)
}

defaultLogFormatter is the default log format function Logger middleware uses.

Functions

func AuthMiddleWare

func AuthMiddleWare() gin.HandlerFunc

func CheckNumber

func CheckNumber(
	v *validator.Validate, topStruct reflect.Value, currentStructOrField reflect.Value,
	field reflect.Value, fieldType reflect.Type, fieldKind reflect.Kind, param string,
) bool

func Cors

func Cors() gin.HandlerFunc

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

func HeaderMiddleWare

func HeaderMiddleWare() gin.HandlerFunc

func NewAddrWithContext

func NewAddrWithContext(ctx context.Context) string

func RespMiddleWare

func RespMiddleWare() gin.HandlerFunc

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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