web

package
v0.0.86-3 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2021 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RespondError

func RespondError(w http.ResponseWriter, err error)

RespondError returns a validation error else

func RespondErrorMessage

func RespondErrorMessage(w http.ResponseWriter, code int, message string)

RespondErrorMessage makes the error response with payload as json format

func RespondJSON

func RespondJSON(w http.ResponseWriter, status int, payload interface{})

RespondJSON makes the response with payload as json format

func UnmarshalJSON

func UnmarshalJSON(r *http.Request, target interface{}) error

UnmarshalJSON checks for empty body and then parses JSON into the target

Types

type HTTPError added in v0.0.2

type HTTPError struct {
	HTTPStatus int
	ErrorKey   string
}

HTTPError Represent an error to be sent back on repsonse

func NewHTTPError added in v0.0.2

func NewHTTPError(err string, httpStatus int) HTTPError

NewHTTPError creates an new instance of HTTP Error

func (HTTPError) Error added in v0.0.2

func (err HTTPError) Error() string

Error returns the error string

type ValidationError added in v0.0.2

type ValidationError struct {
	ErrorKey string            `json:"errorKey"`
	Errors   map[string]string `json:"errors"`
}

ValidationError is an error indicating error in validations

func NewValidationError added in v0.0.2

func NewValidationError(err string, failedValidations map[string]string) ValidationError

NewValidationError creates an new instance of Validation Error

func (ValidationError) Error added in v0.0.2

func (e ValidationError) Error() string

Jump to

Keyboard shortcuts

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