mgin

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2019 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultLimit = 20

修改全局 limit 大小

Variables

This section is empty.

Functions

func GetPage

func GetPage(c *gin.Context) int

GetPage 保证了各接口的page处理是一致的

func GetPageLimit

func GetPageLimit(c *gin.Context, limit int) int

GetPageLimit 自定义单个请求 limit 大小

func MarkError

func MarkError(v ...interface{})

MarkError 将错误 存入日志

Types

type Error

type Error interface {
	error
	Code() int
}

Error 带有错误码 与 错误信息的错误类

func ErrNew

func ErrNew(code int, text string) Error

ErrNew returns an error that formats as the given text.

type Gin

type Gin struct {
	C *gin.Context
}

Gin 实体

func GetGin

func GetGin(c *gin.Context) Gin

GetGin 获取Gin

func (*Gin) Response

func (g *Gin) Response(httpCode, errCode int, msg string, data interface{})

Response

func (*Gin) Response400

func (g *Gin) Response400(err error)

Response400 返回失败

func (*Gin) Response400Str

func (g *Gin) Response400Str(errStr string)

Response400Str 返回自定义字错误内容

func (*Gin) Response500

func (g *Gin) Response500(err error)

Response500 返回失败

func (*Gin) ResponseCodeError

func (g *Gin) ResponseCodeError(error Error)

ResponseFailError 返回自定义的错误码

func (*Gin) ResponseFailValidParam

func (g *Gin) ResponseFailValidParam(err error)

ResponseFailValidParam 验证参数错误

func (*Gin) ResponseSuc

func (g *Gin) ResponseSuc(data interface{})

ResponseSuc 返回成功

func (*Gin) ResponseSucNoData

func (g *Gin) ResponseSucNoData()

ResponseSucNoData 返回成功

Jump to

Keyboard shortcuts

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