Documentation
¶
Index ¶
- Constants
- func Error(w http.ResponseWriter, message string, statuses ...int) error
- func ErrorCode(w http.ResponseWriter, message string, code int, statuses ...int) error
- func ErrorCodeData(w http.ResponseWriter, message string, code int, data interface{}, ...) error
- func Fail(w http.ResponseWriter, data interface{}, statuses ...int) error
- func Success(w http.ResponseWriter, data interface{}, statuses ...int) error
- func Write(w http.ResponseWriter, body Body, statuses ...int) error
- type Body
Constants ¶
View Source
const ( StatusError = "error" StatusFail = "fail" StatusSuccess = "success" )
Status constants
Variables ¶
This section is empty.
Functions ¶
func Error ¶
func Error(w http.ResponseWriter, message string, statuses ...int) error
Error writes error body with the given message.
func ErrorCodeData ¶
func ErrorCodeData(w http.ResponseWriter, message string, code int, data interface{}, statuses ...int) error
ErrorCodeData writes error body with the given message, code and data.
func Fail ¶
func Fail(w http.ResponseWriter, data interface{}, statuses ...int) error
Fail writes failed body with the given data.
Types ¶
type Body ¶
type Body struct { // The status indicates the execution result of request, // it can be one of "success", "fail" and "error". Status string `json:"status"` Data interface{} `json:"data,omitempty"` Message string `json:"message,omitempty"` Code int `json:"code,omitempty"` }
Body contains
Click to show internal directories.
Click to hide internal directories.