result

package
v0.0.0-...-a2093d6 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: LGPL-2.1 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeBoolOk   = true
	CodeIntOk    = 0
	CodeBoolFail = false
)
View Source
const (
	OK           = "OK"
	Fail         = "Fail"
	Created      = "Created"
	Accepted     = "Accepted"
	NoContent    = "No Content"
	ResetContent = "Reset Content"

	BadRequest   = "Bad Request"
	Unauthorized = "Unauthorized"
	Forbidden    = "Forbidden"
	NotFound     = "Not Found"

	InternalServerError   = "Internal Server Error"
	InternalServerTimeout = "Internal Server Processing Timeout"
)
View Source
const (
	MessageOK           = "请求成功"
	MessageCreated      = "已成功创建资源"
	MessageAccepted     = "已经接受请求, 处理中"
	MessageNoContent    = "处理成功, 无其他响应信息"
	MessageResetContent = "已成功重置数据"

	MessageFail         = "请求失败"
	MessageBadRequest   = "请求的语法错误,服务器无法理解"
	MessageUnauthorized = "身份未认证"
	MessageForbidden    = "没有权限, 请求被服务器拒绝了"
	MessageNotFound     = "所请求的资源不存在"

	MessageInternalServerError   = "服务器内部错误, 无法完成请求"
	MessageInternalServerTimeout = "服务器处理超时"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Err

type Err struct {
	Code    interface{} `json:"code"`
	Message string      `json:"message"`
	// contains filtered or unexported fields
}

func Error

func Error(code interface{}, msg string) *Err

func Error2Err

func Error2Err(err error, code interface{}) *Err

func WrapError

func WrapError(err error, code interface{}, msg string) *Err

func WrapErrorf

func WrapErrorf(err error, code interface{}, format string, args ...interface{}) *Err

func (*Err) Error

func (err *Err) Error() string

func (*Err) StatusCode

func (err *Err) StatusCode() int

func (*Err) WithStatusCode

func (err *Err) WithStatusCode(statusCode int) *Err

type Json

type Json map[string]interface{}

func (Json) Get

func (j Json) Get(key string) interface{}

func (Json) Set

func (j Json) Set(key string, val interface{}) Json

func (Json) String

func (j Json) String() string

type Result

type Result struct {
	Code    interface{} `json:"code"`
	Message string      `json:"message"`
	Data    interface{} `json:"data"`
	// contains filtered or unexported fields
}

func Failed

func Failed(err error) *Result

func New

func New() *Result

func Succeed

func Succeed(data interface{}) *Result

func (*Result) StatusCode

func (res *Result) StatusCode() int

func (*Result) WithCode

func (res *Result) WithCode(code interface{}) *Result

func (*Result) WithMessage

func (res *Result) WithMessage(msg string) *Result

func (*Result) WithStatusCode

func (res *Result) WithStatusCode(statusCode int) *Result

Jump to

Keyboard shortcuts

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