api

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2021 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SimpleValidationErrors

func SimpleValidationErrors(verr validator.ValidationErrors) map[string]string

SimpleValidationErrors returns a string map formatted in a descriptive way based on the given validator.ValidationErrors.

Types

type APIError

type APIError struct {
	Status  int    // HTTP status returned to client.
	Err     error  // Error that occurred.
	Message string // Additional information about error returned to client.

}

APIError represents an error that occurred during an operation on an endpoint.

func NewAPIError

func NewAPIError(status int, err error, message string) *APIError

NewAPIError creates a new APIError with the given status, error, and message.

func (*APIError) Error

func (e *APIError) Error() string

Error returns a string representation of the APIError.

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

Unwrap returns the underlying error that caused the APIError.

type ValidationError

type ValidationError struct {
	Field  string `json:"field"`
	Reason string `json:"reason"`
}

ValidationError represents an error that was caused by an invalid request.

func DescriptiveValidationErrors

func DescriptiveValidationErrors(verr validator.ValidationErrors) []ValidationError

DescriptiveValidationErrors returns a slice of ValidationErrors formatted in a descriptive way based on the given validator.ValidationErrors.

Jump to

Keyboard shortcuts

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