utils

package
v0.0.0-...-db31d19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 19, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package utils provides utilities to handle common activities such as logging, error handling, etc.

Index

Constants

This section is empty.

Variables

Log serves as a wrapper around the underlying logging implementation to provide a consistent logging framework independent of underlying logger

View Source
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 LoggerInit

func LoggerInit(lvl string)

LoggerInit initializes the logger

Types

type Error

type Error struct {
	Errors map[string]interface{} `json:"errors"`
}

func NewError

func NewError(code int, err error) Error

func NewValidatorError

func NewValidatorError(vErrors []ValidationError) Error

func ResourceNotFound

func ResourceNotFound() Error

func Unauthorized

func Unauthorized() Error

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

func (*Validator) Validate

func (v *Validator) Validate(i interface{}) error

Validate runs validation over a given object. Validation rules are defined on the model (struct) object.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL