response

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyData struct{}

Functions

func DynamicRespErr added in v0.6.2

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

DynamicRespErr 自适应返回,error 是定义的就按定义的返回,否则按 500 返回并返回 err 的内容

func RespError

func RespError(ctx *gin.Context, c code.MyCode)

func RespErrorInvalidParams

func RespErrorInvalidParams(ctx *gin.Context, err error)

RespErrorInvalidParams 参数校验不通过(gin should bind)

func RespErrorWithMsg

func RespErrorWithMsg(ctx *gin.Context, code code.MyCode, errMsg string)

func RespGrpcErrorWithMsg

func RespGrpcErrorWithMsg(ctx *gin.Context, code code.MyCode, err error)

func RespSuccess

func RespSuccess(ctx *gin.Context, data interface{})

func RespSuccessPagination

func RespSuccessPagination(ctx *gin.Context, pageIndex, pageSize int, total int64, data interface{})

RespSuccessPagination 分页数据返回

func RespSuccessWithMsg

func RespSuccessWithMsg(ctx *gin.Context, data interface{}, msg string)

Types

type PaginateResp

type PaginateResp struct {
	PageIndex int         `json:"page_index"`
	PageSize  int         `json:"page_size"`
	Total     int64       `json:"total"`
	List      interface{} `json:"list"`
}

type RespData

type RespData struct {
	Code code.MyCode `json:"code"`
	Msg  string      `json:"msg"`
	Data interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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