errorshandler

package
v0.0.0-...-92f7cd3 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Handler

func Handler(logger log.ILogger) routing.Handler

Handler creates a middleware that handles panics and errors encountered during HTTP request processing.

Types

type Response

type Response struct {
	Status  int         `json:"-"`
	Message string      `json:"message"`
	Details interface{} `json:"details,omitempty"`
}

Response is the response that represents an error.

func BadRequest

func BadRequest(msg string) Response

BadRequest creates a new error response representing a bad request (HTTP 400)

func Forbidden

func Forbidden(msg string) Response

Forbidden creates a new error response representing an authorization failure (HTTP 403)

func InternalServerError

func InternalServerError(msg string) Response

InternalServerError creates a new error response representing an internal server error (HTTP 500)

func InvalidInput

func InvalidInput(errs validation.Errors) Response

InvalidInput creates a new error response representing a data validation error (HTTP 400).

func NotFound

func NotFound(msg string) Response

NotFound creates a new error response representing a resource-not-found error (HTTP 404)

func Success

func Success() Response

Success returns the struct for success response

func SuccessMessage

func SuccessMessage() Response

SuccessMessage returns the struct for success response with only message

func Unauthorized

func Unauthorized(msg string) Response

Unauthorized creates a new error response representing an authentication/authorization failure (HTTP 401)

func (Response) Error

func (e Response) Error() string

Error is required by the error interface.

func (Response) StatusCode

func (e Response) StatusCode() int

StatusCode is required by routing.HTTPError interface.

Jump to

Keyboard shortcuts

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