GinCtx

package module
v0.0.0-...-59a02f0 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2020 License: MIT Imports: 3 Imported by: 0

README

ginContextEnhance

Enhanced gin.Context

Documentation

Index

Constants

View Source
const (
	InvalidJWTErr = 4000 + iota
	JWTGenErr
	UnknownErr
	NoSuchSQLDataErr
	ContextErr
	NoDesiredRequestDataErr
	RemoteAPIErr
	WsErr
	SessionExpiredErr
	NoFreeSessionIDErr
	DBErr
	ParamOrQueryErr
	NoPrivilegeErr
	LocalIOErr
)

Errors

View Source
const (
	NoErr = 2000 + iota
)

Variables

View Source
var ErrCodeDict = map[int]string{
	InvalidJWTErr:           "JWT 无效或错误!",
	JWTGenErr:               "无法生成有效的 JWT!",
	UnknownErr:              "未知错误",
	NoSuchSQLDataErr:        "无此数据或用户!",
	ContextErr:              "无法从 Context 中获取键值对",
	NoDesiredRequestDataErr: "请求体中的数据格式或内容不正确!",
	RemoteAPIErr:            "调用微信api获取数据时出现错误!",
	WsErr:                   "处理websocket过程中出错!",
	SessionExpiredErr:       "SessionID 过期或未请求过 SessionId!",
	DBErr:                   "数据库读/写出错",
	ParamOrQueryErr:         "请求携带的参数错误",
	NoPrivilegeErr:          "用户没有所需的特权",
}

Functions

func Wrapper

func Wrapper(myCtxHandler func(*Context)) func(*gin.Context)

Types

type Context

type Context struct {
	*gin.Context
}

func (*Context) RepCtxErrThenAbort

func (c *Context) RepCtxErrThenAbort()

func (*Context) RepDBErrThenAbort

func (c *Context) RepDBErrThenAbort()

func (*Context) RepHttpOK

func (c *Context) RepHttpOK(msg string)

func (*Context) RepJWTErrThenAbort

func (c *Context) RepJWTErrThenAbort()

func (*Context) RepJsonOk

func (c *Context) RepJsonOk(j interface{})

func (*Context) RepLocalIOErr

func (c *Context) RepLocalIOErr()

func (*Context) RepNoDesiredDataErrThenAbort

func (c *Context) RepNoDesiredDataErrThenAbort()

func (*Context) RepNoPrivilegeErr

func (c *Context) RepNoPrivilegeErr()

func (*Context) RepNoSQLDataErrThenAbort

func (c *Context) RepNoSQLDataErrThenAbort()

func (*Context) RepNoSessionIDErr

func (c *Context) RepNoSessionIDErr()

func (*Context) RepParamOrQueryErrThenAbort

func (c *Context) RepParamOrQueryErrThenAbort()

func (*Context) RepRemoteApiErrThenAbort

func (c *Context) RepRemoteApiErrThenAbort()

func (*Context) RepSessionExpireErrThenAbort

func (c *Context) RepSessionExpireErrThenAbort()

func (*Context) RepWebSocketErrThenAbort

func (c *Context) RepWebSocketErrThenAbort()

func (*Context) ReportErr

func (c *Context) ReportErr(errCode int, errMsg string)

type RetMessage

type RetMessage struct {
	ErrorCode int    `json:"error_code"`
	Msg       string `json:"msg"`
}

func ExportErr

func ExportErr(errCode int) RetMessage

Jump to

Keyboard shortcuts

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