Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDataFromBody ¶ added in v0.1.2
func GetDataFromBody(body io.ReadCloser, v interface{}) error
GetDataFromBody 获取body中的数据
func Success ¶
func Success(w http.ResponseWriter, data interface{})
Success use to response success data
Types ¶
type Data ¶
type Data struct {
Code *int `json:"code"` // 自定义返回码 0:表示正常
Type string `json:"type,omitempty"` // 数据类型, 可以缺省
Namespace string `json:"namespace,omitempty"` // 异常的范围
Reason string `json:"reason,omitempty"` // 异常原因
Message string `json:"message,omitempty"` // 关于这次响应的说明信息
Data interface{} `json:"data,omitempty"` // 返回的具体数据
}
Data to be used by controllers.
type Response ¶
type Response interface {
http.ResponseWriter
http.Flusher
// Status returns the status code of the response or 0 if the response has
// not been written
Status() int
// Written returns whether or not the ResponseWriter has been written.
Written() bool
// Size returns the size of the response body.
Size() int
// Before allows for a function to be called before the ResponseWriter has been written to. This is
// useful for setting headers or any other operations that must happen before a response has been written.
Before(func(Response))
}
Response is a wrapper around http.ResponseWriter that provides extra information about the response. It is recommended that middleware handlers use this construct to wrap a responsewriter if the functionality calls for it.
func NewResponse ¶
func NewResponse(rw http.ResponseWriter) Response
NewResponse creates a ResponseWriter that wraps an http.ResponseWriter
Click to show internal directories.
Click to hide internal directories.