xgin

package
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeUnknown        = -1
	CodeSuccess        = 0
	CodeBindJsonFailed = 1001 + iota
	CodePreCheckFailed
)

Variables

This section is empty.

Functions

func DELETE

func DELETE(context *gin.Context, handler func(pathParams map[string]string) (interface{}, error))

func Failed

func Failed(c *gin.Context, err error)

func GET

func GET(context *gin.Context, handler func(pathParams map[string]string) (interface{}, error))

func Ok

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

func POST

func POST(context *gin.Context, handler func(receive interface{}, pathParams map[string]string) (interface{}, error), receive interface{})

func PUT

func PUT(context *gin.Context, handler func(receive interface{}, pathParams map[string]string) (interface{}, error), receive interface{})

func Response

func Response(c *gin.Context, result Result)

Types

type IPreCheck

type IPreCheck interface {
	PreCheck() *ParamError
}

type ParamError

type ParamError struct {
	IllegalParams []string
}

func NewParamError

func NewParamError() *ParamError

func (*ParamError) Add

func (err *ParamError) Add(paramName string)

func (ParamError) Error

func (err ParamError) Error() string

func (ParamError) String

func (err ParamError) String() string

type Result

type Result struct {
	Code       int64       `json:"code"`
	Data       interface{} `json:"data,omitempty"`
	Err        error       `json:"error,omitempty"`
	HttpStatus int         `json:"-"`
}

func NewResult

func NewResult(code int64, data interface{}, err error, status int) Result

type ResultErr

type ResultErr struct {
	Code       int64
	Err        error
	HttpStatus int
}

func CodeErr

func CodeErr(code int64, err error) ResultErr

func DefaultErr

func DefaultErr(err error) ResultErr

func NewResultErr

func NewResultErr(code int64, err error, httpStatus int) ResultErr

func StatusErr

func StatusErr(err error, httpStatus int) ResultErr

func (ResultErr) Error

func (resultErr ResultErr) Error() string

Jump to

Keyboard shortcuts

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