render

package
v0.0.0-...-3b47b55 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeOk      = 0  // OK
	CodeErr     = -1 // general error
	CodeAuthErr = -2 // unauthenticated request
)

Variables

This section is empty.

Functions

func ErrorJSON

func ErrorJSON(w http.ResponseWriter, code int, err string, status int)

ErrorCode writes the json-encoded error message to the response.

func GzJSON

func GzJSON(w http.ResponseWriter, v interface{}, status int)

GzJSON writes the json-encoded error message to the response with a 400 bad request status code.

func JSON

func JSON(w http.ResponseWriter, v interface{}, status int)

JSON writes the json-encoded error message to the response with a 400 bad request status code.

Types

type DataModel

type DataModel map[string]interface{}

result data

type Result

type Result struct {
	Code   int         `json:"code"`             // return code
	Msg    string      `json:"msg"`              // message
	Data   interface{} `json:"data,omitempty"`   // data object
	Result interface{} `json:"result,omitempty"` // result data object
}

Result represents a common-used result struct.

func NewResult

func NewResult() *Result

NewResult creates a result with Code=0, Msg="", Data=nil.

func (*Result) AuthError

func (r *Result) AuthError(err error)

func (*Result) Error

func (r *Result) Error(err error)

Jump to

Keyboard shortcuts

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