Documentation ¶
Index ¶
- func ReadEntity(r *http.Request, x interface{}) error
- func Return(r *http.Request, w http.ResponseWriter, code int, reb ResponseBody)
- func ReturnBcodeError(r *http.Request, w http.ResponseWriter, err error)
- func ReturnError(r *http.Request, w http.ResponseWriter, code int, msg string)
- func ReturnList(r *http.Request, w http.ResponseWriter, listAllNumber, page int, ...)
- func ReturnNoFomart(r *http.Request, w http.ResponseWriter, code int, reb interface{})
- func ReturnResNotEnough(r *http.Request, w http.ResponseWriter, eventID, msg string)
- func ReturnSuccess(r *http.Request, w http.ResponseWriter, datas interface{})
- func ReturnValidationError(r *http.Request, w http.ResponseWriter, err url.Values)
- func ValidateStruct(x interface{}) error
- 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 ErrBadRequest
- type ResponseBody
- type Result
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadEntity ¶
ReadEntity reads entity from http.Request
func Return ¶
func Return(r *http.Request, w http.ResponseWriter, code int, reb ResponseBody)
Return 自定义
func ReturnBcodeError ¶
func ReturnBcodeError(r *http.Request, w http.ResponseWriter, err error)
ReturnBcodeError bcode error
func ReturnError ¶
ReturnError 返回错误信息
func ReturnList ¶
func ReturnList(r *http.Request, w http.ResponseWriter, listAllNumber, page int, list interface{})
ReturnList return list with page and count
func ReturnNoFomart ¶
func ReturnNoFomart(r *http.Request, w http.ResponseWriter, code int, reb interface{})
ReturnNoFomart http return no format result
func ReturnResNotEnough ¶
func ReturnResNotEnough(r *http.Request, w http.ResponseWriter, eventID, msg string)
ReturnResNotEnough http return node resource not enough, http code = 412
func ReturnSuccess ¶
func ReturnSuccess(r *http.Request, w http.ResponseWriter, datas interface{})
ReturnSuccess 成功返回
func ReturnValidationError ¶
ReturnValidationError 参数错误返回
func ValidateStruct ¶
func ValidateStruct(x interface{}) error
ValidateStruct validates a structs exposed fields.
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 ErrBadRequest ¶
type ErrBadRequest struct {
// contains filtered or unexported fields
}
ErrBadRequest -
func (ErrBadRequest) Error ¶
func (e ErrBadRequest) Error() string
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