response

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const MIMEApplicationJSONCharsetUTF8 = "application/json; charset=utf-8"

Variables

This section is empty.

Functions

func APIException

func APIException(c *gin.Context, code int, msg string, data any)

APIException 通用异常处理

func APIFailure

func APIFailure(c *gin.Context, msg string, data any)

APIFailure 返回失败, 状态码: 400

func APISuccess

func APISuccess(c *gin.Context, data any, count int)

APISuccess 返回成功, 状态码: 200

func APISuccessBytes

func APISuccessBytes(c *gin.Context, data []byte, count int)

APISuccessBytes 返回成功, JSON 字节数据, 状态码: 200

func APISuccessBytesData

func APISuccessBytesData(data []byte, count int) []byte

APISuccessBytesData API 请求成功返回值(JSON Bytes)

func APISuccessNil

func APISuccessNil(c *gin.Context)

APISuccessNil 返回成功, 无数据, 状态码: 200

func TxtException

func TxtException(c *gin.Context, code int, msg string)

TxtException 异常处理, 文本消息

func TxtMsg

func TxtMsg(c *gin.Context, msg string)

TxtMsg 返回文本消息

Types

type APIData

type APIData struct {
	OK    int    `json:"ok"`
	Code  int    `json:"code"`
	Msg   string `json:"msg"`
	Data  any    `json:"data"`
	Count int    `json:"count"`
}

APIData API 标准返回, 内部规范 ok: 1, code: 0 成功; ok: 0, code: 1 失败 成功时 msg 必定为空

func APIFailureData

func APIFailureData(msg string, data any) *APIData

APIFailureData API 请求失败返回值

func APISuccessData

func APISuccessData(data any, count int) *APIData

APISuccessData API 请求成功返回值

func APISuccessNilData

func APISuccessNilData() *APIData

APISuccessNilData API 请求成功返回, 无数据

Jump to

Keyboard shortcuts

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