Documentation ¶
Overview ¶
Package utils provides utilities to handle common activities such as logging, error handling, etc.
Index ¶
- Variables
- func ArrayContains(arr []string, str string) bool
- func IndexOf(element string, arr []string) int
- func IsUniqueConstraintError(err error, constraintName string) bool
- func LoggerInit(lvl string)
- func RemoveIndex(arr []string, index int) []string
- type APIError
- type ValidationError
- type Validator
Constants ¶
This section is empty.
Variables ¶
var Log *log.MyLogger
Log serves as a wrapper around the underlying logging implementation to provide a consistent logging framework independent of underlying logger
var LogMiddleware echo.MiddlewareFunc
LogMiddleware serves as a wrapper around the underlying middleware logging implementation to provide a consistent logging framework independent of underlying logger
Functions ¶
func ArrayContains ¶
func IsUniqueConstraintError ¶
IsUniqueConstraintError checks if the given error and constraint name represents a unique constraint
func RemoveIndex ¶
Types ¶
type APIError ¶
type APIError struct { Model string `json:"model"` Code int `json:"code"` Message string `json:"message"` Errors []interface{} `json:"errors"` }
func ResourceNotFound ¶
func ResourceNotFound() APIError
func Unauthorized ¶
func Unauthorized() APIError
func ValidatorError ¶
func ValidatorError(model interface{}, vErrors []ValidationError) APIError
type ValidationError ¶
type ValidationError struct { Message string Field string Condition string ConditionParameters string ReceivedValue interface{} }
ValidationError represents a structured validation error object to be used on responses
func GetValidationErrors ¶
func GetValidationErrors(err validator.ValidationErrors) []ValidationError
type Validator ¶
type Validator struct {
// contains filtered or unexported fields
}
Validator defines the structure of the Validator object
func NewValidator ¶
func NewValidator() *Validator
NewValidator returns create a new validator object