response

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: Apache-2.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

自定义响应 辅助方法层

Index

Constants

View Source
const (
	SUCCESS = 0
	ERROR   = 500
)
View Source
const (
	SearchSuccess  = "SearchSuccess"
	DeleteSuccess  = "DeleteSuccess"
	OperateSuccess = "OperateSuccess"
	LogoutSuccess  = "LogoutSuccess"
	LinkSuccess    = "LinkSuccess"
	LoginSuccess   = "LoginSuccess"
)

Variables

This section is empty.

Functions

func ErrorToErrorCode

func ErrorToErrorCode(err error) *MyError

处理异常(业务异常和默认异常)

Types

type Response

type Response struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

自定义响应方法

func (*Response) DealErr

func (this *Response) DealErr(err error) (errorTrace []string)

trace

func (*Response) Error

func (this *Response) Error(ctx *fiber.Ctx, err error) error

错误信息

func (*Response) JsonDealErr

func (this *Response) JsonDealErr(err error) string

func (*Response) Output

func (this *Response) Output(ctx *fiber.Ctx, data interface{}) error

输出

func (*Response) ReturnValOrNull

func (this *Response) ReturnValOrNull(value, empty interface{}) interface{}

func (*Response) SliceReturnValOrNull

func (this *Response) SliceReturnValOrNull(value []string, empty interface{}) interface{}

func (*Response) Success

func (this *Response) Success(ctx *fiber.Ctx, msg string, data interface{}) error

正确信息

Jump to

Keyboard shortcuts

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