Documentation ¶
Index ¶
- func Return(r *http.Request, w http.ResponseWriter, code int, reb ResponseBody)
- func ReturnError(r *http.Request, w http.ResponseWriter, code int, msg string)
- func ReturnList(r *http.Request, w http.ResponseWriter, listAllNumber, page int, ...)
- func ReturnSuccess(r *http.Request, w http.ResponseWriter, datas interface{})
- func ReturnValidationError(r *http.Request, w http.ResponseWriter, err url.Values)
- func ValidatorMapRequest(r *http.Request, rule govalidator.MapData, message govalidator.MapData) (map[string]interface{}, url.Values)
- func ValidatorRequestMapAndErrorResponse(r *http.Request, w http.ResponseWriter, rule govalidator.MapData, ...) (map[string]interface{}, bool)
- func ValidatorRequestStructAndErrorResponse(r *http.Request, w http.ResponseWriter, data interface{}, ...) bool
- func ValidatorStructRequest(r *http.Request, data interface{}, message govalidator.MapData) url.Values
- type ResponseBody
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Return ¶
func Return(r *http.Request, w http.ResponseWriter, code int, reb ResponseBody)
Return 自定义
func ReturnError ¶
ReturnError 返回错误信息
func ReturnList ¶
func ReturnList(r *http.Request, w http.ResponseWriter, listAllNumber, page int, datas ...interface{})
ReturnList 返回列表
func ReturnSuccess ¶
func ReturnSuccess(r *http.Request, w http.ResponseWriter, datas interface{})
ReturnSuccess 成功返回
func ReturnValidationError ¶
ReturnValidationError 参数错误返回
func ValidatorMapRequest ¶
func ValidatorMapRequest(r *http.Request, rule govalidator.MapData, message govalidator.MapData) (map[string]interface{}, url.Values)
ValidatorMapRequest 验证请求数据从map
func ValidatorRequestMapAndErrorResponse ¶
func ValidatorRequestMapAndErrorResponse(r *http.Request, w http.ResponseWriter, rule govalidator.MapData, messgae govalidator.MapData) (map[string]interface{}, bool)
ValidatorRequestMapAndErrorResponse 验证并格式化请求数据为对象 retrun true 继续执行 return false 参数错误,终止
func ValidatorRequestStructAndErrorResponse ¶
func ValidatorRequestStructAndErrorResponse(r *http.Request, w http.ResponseWriter, data interface{}, message govalidator.MapData) bool
ValidatorRequestStructAndErrorResponse 验证并格式化请求数据为对象 retrun true 继续执行 return false 参数错误,终止
func ValidatorStructRequest ¶
func ValidatorStructRequest(r *http.Request, data interface{}, message govalidator.MapData) url.Values
ValidatorStructRequest 验证请求数据 data 传入指针
Types ¶
type ResponseBody ¶
type ResponseBody struct { ValidationError url.Values `json:"validation_error,omitempty"` Msg string `json:"msg,omitempty"` Bean interface{} `json:"bean,omitempty"` List interface{} `json:"list,omitempty"` //数据集总数 ListAllNumber int `json:"number,omitempty"` //当前页码数 Page int `json:"page,omitempty"` }
ResponseBody api返回数据格式
func ParseResponseBody ¶
func ParseResponseBody(red io.ReadCloser, dataType string) (re ResponseBody, err error)
ParseResponseBody 解析成ResponseBody
Click to show internal directories.
Click to hide internal directories.