echo

package
v0.0.0-...-7232a66 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HTTP_STATE_200 = 200
	HTTP_STATE_401 = 401
	HTTP_STATE_403 = 403
)

Variables

View Source
var (
	SUCCESS                = ErrorStruct{0, "Successful", []interface{}{}}
	ERROR                  = ErrorStruct{7, "Failed", []interface{}{}}
	SYSTEM_ERROR           = ErrorStruct{100000, "系统错误", []interface{}{}}
	PARAMS_ERROR           = ErrorStruct{100001, "参数错误", []interface{}{}}
	ACCOUNT_PASSWORD_ERROR = ErrorStruct{100020, "账号密码错误", []interface{}{}}
)
View Source
var ResultPool *sync.Pool

Functions

func OutputError

func OutputError(c *gin.Context) func(error ErrorStruct)

func OutputErrorDetail

func OutputErrorDetail(c *gin.Context) func(data interface{}, error ErrorStruct)

func OutputErrorDetailWithHttpState

func OutputErrorDetailWithHttpState(c *gin.Context) func(data interface{}, error ErrorStruct, httpState int)

func OutputErrorWithHttpState

func OutputErrorWithHttpState(c *gin.Context) func(error ErrorStruct, httpState int)

func OutputFail

func OutputFail(c *gin.Context)

func OutputFailDetail

func OutputFailDetail(c *gin.Context) func(data interface{}, message string)

func OutputFailMsg

func OutputFailMsg(c *gin.Context) func(message string)

func OutputFailedPermission

func OutputFailedPermission(c *gin.Context) func(data interface{}, message string)

func OutputFailedSignature

func OutputFailedSignature(c *gin.Context) func(data interface{}, message string)

func OutputOk

func OutputOk(c *gin.Context)

func OutputOkData

func OutputOkData(c *gin.Context) func(data interface{})

func OutputOkDetail

func OutputOkDetail(c *gin.Context) func(data interface{}, message string)

func OutputOkMsg

func OutputOkMsg(c *gin.Context) func(message string)

Types

type ErrorResult

type ErrorResult struct {
	// contains filtered or unexported fields
}

func Result

func Result(errs ...interface{}) *ErrorResult

func (*ErrorResult) Unwrap

func (r *ErrorResult) Unwrap(errType ...ErrorStruct) interface{}

type ErrorStruct

type ErrorStruct struct {
	Code    int
	Message string
	Error   interface{}
}

type JSONResult

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

func NewJSONResult

func NewJSONResult(message string, code int, result interface{}) *JSONResult

type PageResult

type PageResult struct {
	List     interface{} `json:"data"`
	Total    int64       `json:"total"`
	Page     uint64      `json:"page"`
	PageSize uint64      `json:"pageSize"`
	Success  bool        `json:"success"`
}

type ResultFunc

type ResultFunc func(message string, code int, result interface{}) func(httpState int)

func Output

func Output(c *gin.Context) ResultFunc

Jump to

Keyboard shortcuts

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