servers

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2020 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSON

func JSON(c *gin.Context, code int, data ...interface{})

JSON 标准http status code应答

func JSONCustom

func JSONCustom(c *gin.Context, code Code, data ...interface{})

JSONCustom http.StatusBadRequest式应答,自定义code码应答,一般给前端判断使用

func JSONDetail

func JSONDetail(c *gin.Context, err error, data ...interface{})

JSONDetail http.StatusBadRequest式应答,含detail字段,调试使用

func JSONs added in v0.2.3

func JSONs(c *gin.Context, httpCode int, code Code, data ...interface{})

JSONs 标准http status code应答

Types

type Code

type Code interface {
	fmt.Stringer
	Value() int
}

Code custom code interface

type Response

type Response struct {
	Code    int         `json:"code"`
	Message string      `json:"message,omitempty"`
	Detail  string      `json:"detail,omitempty"`
	Data    interface{} `json:"data"`
}

Response 错误信息回复基本格式

Jump to

Keyboard shortcuts

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