uhttp

package module
v0.0.0-...-a97d26c Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: MIT Imports: 9 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 ParseJSONFromCtxReq

func ParseJSONFromCtxReq(v interface{}, c *MyContext) error

func Wrapper

func Wrapper(handler func(*MyContext)) func(*gin.Context)

Types

type MyContext

type MyContext struct {
	*gin.Context
}

func (*MyContext) GetIDFromCtx

func (c *MyContext) GetIDFromCtx() (uint, error)

func (*MyContext) GetStrByKeyFromParam

func (c *MyContext) GetStrByKeyFromParam(key string) (string, error)

func (*MyContext) GetStrByKeyFromQuery

func (c *MyContext) GetStrByKeyFromQuery(key string) (string, error)

func (*MyContext) GetUintByKeyFromParam

func (c *MyContext) GetUintByKeyFromParam(key string) (uint, error)

func (*MyContext) RepCtxErrThenAbort

func (c *MyContext) RepCtxErrThenAbort()

func (*MyContext) RepDBErrThenAbort

func (c *MyContext) RepDBErrThenAbort()

func (*MyContext) RepHttpOK

func (c *MyContext) RepHttpOK(msg string)

func (*MyContext) RepJWTErrThenAbort

func (c *MyContext) RepJWTErrThenAbort()

func (*MyContext) RepJsonOk

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

func (*MyContext) RepLocalIOErr

func (c *MyContext) RepLocalIOErr()

func (*MyContext) RepNoDesiredDataErrThenAbort

func (c *MyContext) RepNoDesiredDataErrThenAbort()

func (*MyContext) RepNoPrivilegeErr

func (c *MyContext) RepNoPrivilegeErr()

func (*MyContext) RepNoSQLDataErrThenAbort

func (c *MyContext) RepNoSQLDataErrThenAbort()

func (*MyContext) RepNoSessionIDErr

func (c *MyContext) RepNoSessionIDErr()

func (*MyContext) RepParamOrQueryErrThenAbort

func (c *MyContext) RepParamOrQueryErrThenAbort()

func (*MyContext) RepRemoteApiErrThenAbort

func (c *MyContext) RepRemoteApiErrThenAbort()

func (*MyContext) RepSessionExpireErrThenAbort

func (c *MyContext) RepSessionExpireErrThenAbort()

func (*MyContext) RepWebSocketErrThenAbort

func (c *MyContext) RepWebSocketErrThenAbort()

func (*MyContext) ReportErr

func (c *MyContext) 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