Documentation ¶
Index ¶
- func RespondError(w http.ResponseWriter, err error)
- func RespondErrorMessage(w http.ResponseWriter, code int, message string)
- func RespondJSON(w http.ResponseWriter, status int, payload interface{})
- func RespondJSONWithXTotalCount(w http.ResponseWriter, status int, count int, payload interface{})
- func UnmarshalJSON(r *http.Request, target interface{}) error
- type HTTPError
- type ValidationError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RespondError ¶
func RespondError(w http.ResponseWriter, err error)
RespondError returns a validation error else
func RespondErrorMessage ¶
func RespondErrorMessage(w http.ResponseWriter, code int, message string)
RespondErrorMessage makes the error response with payload as json format
func RespondJSON ¶
func RespondJSON(w http.ResponseWriter, status int, payload interface{})
RespondJSON makes the response with payload as json format
func RespondJSONWithXTotalCount ¶ added in v0.0.90
func RespondJSONWithXTotalCount(w http.ResponseWriter, status int, count int, payload interface{})
RespondJSONWithXTotalCount makes the response with payload as json format and adds X-Total-Count header
func UnmarshalJSON ¶
UnmarshalJSON checks for empty body and then parses JSON into the target
Types ¶
type HTTPError ¶ added in v0.0.2
HTTPError Represent an error to be sent back on repsonse
func NewHTTPError ¶ added in v0.0.2
NewHTTPError creates an new instance of HTTP Error
type ValidationError ¶ added in v0.0.2
type ValidationError struct { ErrorKey string `json:"errorKey"` Errors map[string]string `json:"errors"` }
ValidationError is an error indicating error in validations
func NewValidationError ¶ added in v0.0.2
func NewValidationError(err string, failedValidations map[string]string) ValidationError
NewValidationError creates an new instance of Validation Error
func (ValidationError) Error ¶ added in v0.0.2
func (e ValidationError) Error() string
Click to show internal directories.
Click to hide internal directories.