response

package
v0.0.0-...-3b5bd2e Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2025 License: MIT Imports: 1 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 *fiber.Ctx, message string) error

BadRequestException 400错误

func ForbiddenException

func ForbiddenException(ctx *fiber.Ctx, message string) error

ForbiddenException 403错误

func InternalServerException

func InternalServerException(ctx *fiber.Ctx, message string) error

InternalServerException 500错误

func JSON

func JSON(ctx *fiber.Ctx, status int, errcode Code, message string, data interface{}) error

JSON 基础返回

func NotFoundException

func NotFoundException(ctx *fiber.Ctx, message string) error

NotFoundException 404错误

func SuccessJSON

func SuccessJSON(ctx *fiber.Ctx, message string, data interface{}) error

SuccessJSON 成功返回

func UnauthorizedException

func UnauthorizedException(ctx *fiber.Ctx, message string) error

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 {
	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