Documentation ¶
Index ¶
- type ErrorResponse
- func BadRequest(msg string) ErrorResponse
- func BuildErrorResponse(err error, trans ut.Translator) ErrorResponse
- func Forbidden(msg string) ErrorResponse
- func InternalServerError(msg string) ErrorResponse
- func NotFound(msg string) ErrorResponse
- func TooLargeEntity(msg string) ErrorResponse
- func Unauthorized(msg string) ErrorResponse
- func UnsupportedMediaType(msg string) ErrorResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ErrorResponse ¶
type ErrorResponse struct { Status int `json:"status"` Message string `json:"message"` Details interface{} `json:"details,omitempty"` }
ErrorResponse is the response that represents an error.
func BadRequest ¶
func BadRequest(msg string) ErrorResponse
BadRequest creates a new error response representing a bad request (HTTP 400).
func BuildErrorResponse ¶
func BuildErrorResponse(err error, trans ut.Translator) ErrorResponse
BuildErrorResponse builds an error response from an error.
func Forbidden ¶
func Forbidden(msg string) ErrorResponse
Forbidden creates a new error response representing an authorization. failure (HTTP 403)
func InternalServerError ¶
func InternalServerError(msg string) ErrorResponse
InternalServerError creates a new error response representing an internal server error (HTTP 500)
func NotFound ¶
func NotFound(msg string) ErrorResponse
NotFound creates a new error response representing a resource-not-found error (HTTP 404)
func TooLargeEntity ¶
func TooLargeEntity(msg string) ErrorResponse
TooLargeEntity creates a new error response representing a an entity larger than limits defined by server (HTTP 413).
func Unauthorized ¶
func Unauthorized(msg string) ErrorResponse
Unauthorized creates a new error response representing an authentication/authorization failure (HTTP 401)
func UnsupportedMediaType ¶ added in v0.3.0
func UnsupportedMediaType(msg string) ErrorResponse
UnsupportedMediaType creates a new error response representing a an unsupported media type (HTTP 415).
func (ErrorResponse) Error ¶
func (e ErrorResponse) Error() string
Error is required by the error interface.
func (ErrorResponse) StatusCode ¶
func (e ErrorResponse) StatusCode() int
StatusCode is required by routing.HTTPError interface.