Documentation
¶
Index ¶
- Constants
- type Binder
- type Error
- func NewError(err error) *Error
- func NewForbiddenError(err ...validator.ValidationError) *Error
- func NewHTTPError(err *echo.HTTPError) *Error
- func NewInternalServerError() *Error
- func NewNotFoundError(err error) *Error
- func NewUnauthorizedError(err ...validator.ValidationError) *Error
- func NewValidationError(err ...validator.ValidationError) *Error
- type Logger
- type Responder
Constants ¶
View Source
const ( TypeValidation = "validation-error" TypeForbidden = "forbidden" TypeNotFound = "data-not-found" TypeInternalServerError = "internal-server-error" TypeHTTP = "http-error" )
Error types for RFC-7807 Problem Details format. See: https://datatracker.ietf.org/doc/html/rfc7807
View Source
const ( TitleValidation = "Your request parameters didn't validate." TitleForbidden = "Your request has been forbidden." TitleNotFound = "Not Found" TitleInternalServerError = "Internal Server Error" )
Titles for RFC-7807 Problem Details format.
View Source
const ( StatusValidation = http.StatusBadRequest // 400 StatusForbidden = http.StatusForbidden // 403 StatusNotFound = http.StatusNotFound // 404 StatusBusinessError = http.StatusUnprocessableEntity // 422 StatusInternalServerError = http.StatusInternalServerError // 500 )
Statuses for RFC-7807 Problem Details format.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Binder ¶
type Binder struct {
// contains filtered or unexported fields
}
type Error ¶
type Error struct {
Type string `json:"type"`
Title string `json:"title"`
Status int `json:"status"`
Detail string `json:"detail,omitempty"`
// InvalidParams contains the explanation of errors in RFC-7807 format.
InvalidParams validator.ValidationErrors `json:"invalid-params,omitempty"` //nolint
}
Error contains error in RFC-7807 Problem Details format.
func NewForbiddenError ¶
func NewForbiddenError(err ...validator.ValidationError) *Error
func NewHTTPError ¶
func NewInternalServerError ¶
func NewInternalServerError() *Error
func NewNotFoundError ¶
func NewUnauthorizedError ¶
func NewUnauthorizedError(err ...validator.ValidationError) *Error
func NewValidationError ¶
func NewValidationError(err ...validator.ValidationError) *Error
type Logger ¶
type Logger interface {
Error(args ...interface{})
}
Logger describes Error and Info functions.
type Responder ¶
type Responder struct {
// contains filtered or unexported fields
}
Responder wraps on echo Context to be used on echo HTTP handlers to construct an HTTP response.
func NewResponder ¶
NewResponder creates and returns pointer to Responder.
func (*Responder) ServeError ¶
ServeError sends a JSON error response with status code.
Click to show internal directories.
Click to hide internal directories.