servers

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 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(w http.ResponseWriter, statusCode int, data ...interface{})

JSON 返回json信息,带标准回复

func JSONCustom

func JSONCustom(w http.ResponseWriter, code Code, data ...interface{})

JSONCustom http.StatusBadRequest式应答,自定义code,提供给前端

func JSONDetail

func JSONDetail(w http.ResponseWriter, err error, data ...interface{})

JSONDetail http.StatusBadRequest式应答,含detail字段,用于debug

Types

type Code

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

Code 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