resp

package module
v0.0.0-...-8e1a190 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentType_JSON = `application/json; charset=utf-8`
)

Variables

View Source
var Simple = NewSimple()
View Source
var Std = NewStandard()

Functions

func SetDefaultResp

func SetDefaultResp(r Resp)

Types

type Resp

type Resp interface {
	New(code int, msg string, data any, other any) To
	NewOK(list ...any) To
	NewErr(code int, msg string) To
}

func NewSimple

func NewSimple() Resp

func NewStandard

func NewStandard() Resp

type StdRespData

type StdRespData struct {
	Data  any `json:"data"`
	Other any `json:"other"`
}

type To

type To interface {
	SetCode(code int)
	SetMsg(msg string)
	SetData(data any)
	SetOther(other any)

	ToJson() []byte
	Value() any        //返回可以JSON编码的对象
	Gin() (int, any)   //返回http状态码code和可以JSON编码的对象
	GinOK() (int, any) //返回http状态码200和可以JSON编码的对象
}

func New

func New(code int, msg string, data any, other any) To

func NewErr

func NewErr(code int, msg string) To

func NewOK

func NewOK(list ...any) To

Jump to

Keyboard shortcuts

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