resp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BizError = iota + 10001
	ParseError
	MysqlError
	RedisError
	TokenError
)

Variables

View Source
var NilBaseError = BaseError{}

Functions

func Response

func Response(w http.ResponseWriter, resp interface{}, err BaseError)

Types

type BaseError added in v0.1.0

type BaseError struct {
	Msg  string `json:"msg"`  //错误信息
	Code int    `json:"code"` //错误码
	Err  error
}

func MustDefaultError added in v0.1.0

func MustDefaultError(err error) BaseError

func MustError added in v0.1.0

func MustError(msg string, err error) BaseError

func NewError added in v0.1.0

func NewError(code int, msg string, err error) BaseError

func (*BaseError) Error added in v0.1.0

func (b *BaseError) Error() string

type Body

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

Jump to

Keyboard shortcuts

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