handlerutil

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound          = errors.New("record not found")
	ErrForbidden         = errors.New("forbidden")
	ErrCredentialInvalid = errors.New("invalid username or password")
	ErrUserAlreadyExists = errors.New("user already exists")
	ErrUnauthorized      = errors.New("unauthorized")
	ErrInternalServer    = errors.New("internal server error")
	ErrInvalidUUID       = errors.New("failed to parse UUID")
	ErrValidation        = errors.New("validation error")
)

Functions

func ParseAndValidateRequestBody

func ParseAndValidateRequestBody(ctx context.Context, v *validator.Validate, r *http.Request, s interface{}) error

func ParseUUID

func ParseUUID(value string) (uuid.UUID, error)

func WriteJSONResponse

func WriteJSONResponse(w http.ResponseWriter, status int, data interface{})

Types

type NotFoundError

type NotFoundError struct {
	Table   string
	Key     string
	Value   string
	Message string
}

func NewNotFoundError

func NewNotFoundError(table, key, value, message string) NotFoundError

func (NotFoundError) Error

func (e NotFoundError) Error() string

func (NotFoundError) Is

func (e NotFoundError) Is(target error) bool

type ValidationError

type ValidationError struct {
	Field   string
	Value   interface{}
	Message string
	Errors  []string
}

func NewValidationError

func NewValidationError(field string, value interface{}, message string) ValidationError

func NewValidationErrorWithErrors

func NewValidationErrorWithErrors(message string, errs []string) ValidationError

func (ValidationError) Error

func (e ValidationError) Error() string

func (ValidationError) Is

func (e ValidationError) Is(target error) bool

Jump to

Keyboard shortcuts

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