response

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2022 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CodeMap = map[Code]string{
	Success:          "请求成功",
	Failed:           "请求失败",
	UnAuthed:         "用户未认证",
	AuthExpired:      "会话过期,请重新登录",
	InternalErr:      "服务器内部错误",
	RequestMethodErr: "请求方式错误",
	RequestParamErr:  "请求参数错误",
	RequestFormErr:   "请求表单错误",
	AccountInfoErr:   "账号信息有误",
}

Functions

func BadRequestException

func BadRequestException(ctx *gin.Context, message string)

BadRequestException 400错误

func ForbiddenException

func ForbiddenException(ctx *gin.Context, message string)

ForbiddenException 403错误

func InternalServerException

func InternalServerException(ctx *gin.Context, message string)

InternalServerException 500错误

func NotFoundException

func NotFoundException(ctx *gin.Context, message string)

NotFoundException 404错误

func ResponseJson

func ResponseJson(ctx *gin.Context, status int, errcode Code, message string, data interface{})

ResponseJson 基础返回

func SuccessJson added in v1.0.3

func SuccessJson(ctx *gin.Context, message string, data interface{})

SuccessJson 成功返回

func UnauthorizedException

func UnauthorizedException(ctx *gin.Context, message string)

UnauthorizedException 401错误

Types

type Code

type Code int
const (
	Success Code = 0
	Failed  Code = 10000 + iota
	UnAuthed
	AuthExpired
	InternalErr
	RequestMethodErr
	RequestParamErr
	RequestFormErr
	AccountInfoErr
)

func (Code) Msg

func (c Code) Msg() string

Msg 返回错误码对应的说明

type JsonResponse

type JsonResponse struct {
	Status    int         `json:"status"`
	ErrCode   Code        `json:"errcode"`
	RequestId string      `json:"requestid"`
	Message   string      `json:"message"`
	Data      interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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