ctx

package
v0.0.0-...-0c396f5 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATUSERROR = iota
	STATUSOK
)
View Source
const ErrorTypePrivate gin.ErrorType = 1 << 0

Variables

This section is empty.

Functions

func Cors

func Cors() gin.HandlerFunc

Cors 跨域设置

func H

H Handler ext gin.content

func Logger

func Logger() gin.HandlerFunc

Logger 日志

func LoggerWithConfig

func LoggerWithConfig(conf gin.LoggerConfig) gin.HandlerFunc

LoggerWithConfig instance a Logger middleware with config.

Types

type Context

type Context struct {
	*gin.Context
}

Context ext content struct

func (*Context) GetUID

func (c *Context) GetUID(auth *ginjwt.GinJWTMiddleware) int

GetUID 根据session获取用户的id

func (*Context) HandlerError

func (c *Context) HandlerError(err error) bool

func (*Context) HandlerOk

func (c *Context) HandlerOk(data interface{})

func (*Context) IsMobile

func (c *Context) IsMobile() bool

IsMobile 判断是否是前端请求

func (*Context) PostFormInt

func (c *Context) PostFormInt(key string) int

PostFormInt 获取form 里面的参数并转成int类型

func (*Context) QueryInt

func (c *Context) QueryInt(key string) int

QueryInt 获取url里面的参数并转成int类型

func (*Context) RespError

func (c *Context) RespError(err string)

func (*Context) UnmarshalFromString

func (c *Context) UnmarshalFromString(o interface{}) (err error)

UnmarshalFromString 把字符串解析到对象里面 o需要传入指针类型

func (*Context) VersionCheck

func (c *Context) VersionCheck(version, version1 int) bool

VersionCheck 数据版本检查

type HandlerFunc

type HandlerFunc func(*Context)

HandlerFunc HandlerFunc

type R

type R struct {
	Status int         `json:"code"`
	Msg    string      `json:"message"`
	Data   interface{} `json:"result"`
}

R api接口返回值

Jump to

Keyboard shortcuts

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