Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( BAD_REQUEST_ERROR = &ErrorResponse{ []ErrorObject{ { Status: http.StatusBadRequest, Title: "Bad Request", }, }, } UNAUTHORIZED_ERROR = &ErrorResponse{ []ErrorObject{ { Status: http.StatusUnauthorized, Title: "Unauthorized", }, }, } FORBIDDEN_ERROR = &ErrorResponse{ []ErrorObject{ { Status: http.StatusForbidden, Title: "Forbidden", }, }, } METHOD_NOT_ALLOWED_ERROR = &ErrorResponse{ []ErrorObject{ { Status: http.StatusMethodNotAllowed, Title: "Method Not Allowed", }, }, } INTERNAL_SERVER_ERROR = &ErrorResponse{ []ErrorObject{ { Status: http.StatusInternalServerError, Title: "Internal Server Error", }, }, } )
Functions ¶
func NewResponseError ¶
func WriteResponseError ¶
func WriteResponseError(w http.ResponseWriter, err error, fallback ...error)
Types ¶
type ErrorObject ¶
type ErrorResponse ¶
type ErrorResponse struct {
Errors []ErrorObject `json:"errors" validate:"required,dive"`
}
func NewErrorResponse ¶
func NewErrorResponse(status int, title string, other ...string) *ErrorResponse
func (*ErrorResponse) Add ¶
func (res *ErrorResponse) Add(err ErrorObject)
func (*ErrorResponse) String ¶
func (res *ErrorResponse) String() string
func (*ErrorResponse) Validate ¶
func (res *ErrorResponse) Validate() (err error)
type ResponseError ¶
func (ResponseError) Error ¶
func (err ResponseError) Error() (s string)
func (ResponseError) Write ¶
func (err ResponseError) Write(w http.ResponseWriter)
Click to show internal directories.
Click to hide internal directories.