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 Customize
func ReturnBcodeError ¶
func ReturnBcodeError(r *http.Request, w http.ResponseWriter, err error)
ReturnBcodeError bcode error
func ReturnError ¶
ReturnError Return error message
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 Returned Successfully
func ReturnValidationError ¶
ReturnValidationError Parameter return error
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 Verify request data from map
func ValidatorRequestMapAndErrorResponse ¶
func ValidatorRequestMapAndErrorResponse(r *http.Request, w http.ResponseWriter, rule govalidator.MapData, messgae govalidator.MapData) (map[string]interface{}, bool)
ValidatorRequestMapAndErrorResponse Validate and format the requested data as an object retrun true Continue execution return false Parameter error, termination
func ValidatorRequestStructAndErrorResponse ¶
func ValidatorRequestStructAndErrorResponse(r *http.Request, w http.ResponseWriter, data interface{}, message govalidator.MapData) bool
ValidatorRequestStructAndErrorResponse Validate and format the requested data as an object retrun true Continue execution return false Parameter error, termination
func ValidatorStructRequest ¶
func ValidatorStructRequest(r *http.Request, data interface{}, message govalidator.MapData) url.Values
ValidatorStructRequest Verify request data data Incoming pointer
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"` //Total number of data sets ListAllNumber int `json:"number,omitempty"` //Current page number Page int `json:"page,omitempty"` }
ResponseBody api return data format
func ParseResponseBody ¶
func ParseResponseBody(red io.ReadCloser, dataType string) (re ResponseBody, err error)
ParseResponseBody Parse into ResponseBody