Documentation ¶
Index ¶
- Variables
- func BadRequest(message string, body ...interface{}) error
- func Conflict(message string, body ...interface{}) error
- func HTTPErrorHandler(err error, c echo.Context)
- func InternalServerError(err error) error
- func JSONValidate(c echo.Context, i interface{}) error
- func Mongo(err error, model string) error
- func MongoCreate(err error, model string) error
- func MongoDelete(err error, model string) error
- func MongoDeleteErr(err error, result *mongo.DeleteResult) error
- func MongoGet(err error, model string) error
- func MongoList(err error, model string) error
- func MongoUpdate(err error, model string) error
- func MongoUpdateErr(err error, result *mongo.UpdateResult) error
- func NotFound(message string, body ...interface{}) error
- type ErrJSONResponse
- type JSONError
- type JSONValidator
- type Response
Constants ¶
This section is empty.
Variables ¶
var ErrMongoDelete = errors.New("no delete document")
ErrMongoDelete represents an delete error in mongo case
var ErrMongoUpdate = errors.New("no updated document")
ErrMongoUpdate represents an update error in mongo case
Functions ¶
func BadRequest ¶ added in v1.0.1
BadRequest creates an echo.HTTPError with the status http.StatusBadRequest
func Conflict ¶ added in v1.0.1
Conflict creates an echo.HTTPError with the status http.StatusConflict
func HTTPErrorHandler ¶ added in v1.0.1
func HTTPErrorHandler(err error, c echo.Context)
HTTPErrorHandler handles echo.HTTPError and return the correct response.
func InternalServerError ¶ added in v0.1.16
InternalServerError creates an echo.HTTPError with the status http.StatusInternalServerError
func JSONValidate ¶ added in v0.1.15
func JSONValidate(c echo.Context, i interface{}) error
JSONValidate validates a json bind in echo.Context. The interface i is used for validation. If the c.Bind(i) or the validation returns errors the function return an APIError.
func MongoCreate ¶ added in v0.1.16
func MongoDelete ¶ added in v0.1.16
func MongoDeleteErr ¶
func MongoDeleteErr(err error, result *mongo.DeleteResult) error
MongoDeleteErr helper for handling delete errors
func MongoUpdate ¶ added in v0.1.16
func MongoUpdateErr ¶
func MongoUpdateErr(err error, result *mongo.UpdateResult) error
MongoUpdateErr helper for handling update errors
Types ¶
type ErrJSONResponse ¶ added in v1.0.1
type ErrJSONResponse struct {
JSONError JSONError
}
func (*ErrJSONResponse) Error ¶ added in v1.0.1
func (e *ErrJSONResponse) Error() string
type JSONError ¶ added in v0.1.15
type JSONError struct {
Errors []string `json:"errors"`
}
JSONError represents a json validation error. Used om return of JSONErrorResponse.
func NewJSONError ¶ added in v1.0.1
JSONErrorResponse creates a response for json validation error.
type JSONValidator ¶ added in v0.1.15
JSONValidator represents the json validator struct.
func (*JSONValidator) Validate ¶ added in v0.1.15
func (cv *JSONValidator) Validate(i interface{}) error
Validate extend JSONValidator with Validate function.