reply

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client(ctx *gin.Context, jm *JsonMsg, opts ...Option)

ReplyData 定义数据返回格式

func Failed added in v1.2.7

func Failed(ctx *gin.Context, msg, err string, others ...gin.H)

Failed 错误数据

func Succeed added in v1.2.7

func Succeed(ctx *gin.Context, msg string, others ...gin.H)

Succeed 正确数据

Types

type JsonMsg

type JsonMsg struct {
	Code int         `json:"code"`
	Msg  string      `json:"msg"`
	Err  *string     `json:"err,omitempty"`
	Data interface{} `json:"data,omitempty"`
	// contains filtered or unexported fields
}

JsonMsg 通用返回格式

type Option

type Option func(*JsonMsg)

Option 函数选项式

func WithCode

func WithCode(code int) Option

WithCode 初始化状态码

func WithErr

func WithErr(err string) Option

WithErr 初始化错误

func WithFlag added in v1.2.4

func WithFlag(is bool) Option

WithFlag 初始化标志位

func WithMsg

func WithMsg(msg string) Option

WithMsg 初始化数据

func WithOther added in v1.2.6

func WithOther(other any) Option

增加其他数据

Jump to

Keyboard shortcuts

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