ret

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 5, 2024 License: MIT Imports: 5 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Success       = ErrorCode{"0", "success"}
	NoAuth        = ErrorCode{"401", "unauthorized!"}
	NoFound       = ErrorCode{"404", "route not found!"}
	InternalError = ErrorCode{"500", "internal error"}
	IllegalParam  = ErrorCode{"400", "illegal param"}
	UnknownErr    = ErrorCode{"999", "unknown error"}
	BizErr        = ErrorCode{"1000", "biz error"}
)

BizError should be greater than 1000 Since we try to use the http code as much as we can

Functions

func BadRequest

func BadRequest(ctx iris.Context, msg ...string)

BadRequest 参数错误

func BizError

func BizError(ctx iris.Context, code string, msg ...string)

BizError 业务错误一般调用此方法

func NotFound

func NotFound(ctx iris.Context)

NotFound 找不到资源

func Ok

func Ok(ctx iris.Context, data ...interface{})

Ok 正常返回

func ServerError

func ServerError(ctx iris.Context, msg ...string)

ServerError 不可遇见的服务器错误, 可以使用此方法

func Unauthorized added in v0.0.3

func Unauthorized(ctx iris.Context, msg ...string)

Unauthorized 未授权

func UnknownError added in v0.0.3

func UnknownError(ctx iris.Context, msg ...string)

UnknownError error that could not be identified

Types

type ErrorCode

type ErrorCode struct {
	Code string
	Msg  string
}

ErrorCode for most defined errors

type Ret

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

Ret return value generic data structure

Jump to

Keyboard shortcuts

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