httperr

package module
v0.0.0-...-527f111 Latest Latest
Warning

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

Go to latest
Published: Jul 18, 2019 License: Apache-2.0 Imports: 6 Imported by: 1

README

httperr

HTTP errors gor Golang

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BadRequest

func BadRequest(err error) error

BadRequest creates an HTTP 500 error

func Errorf

func Errorf(code int, format string, args ...interface{}) error

Errorf creates a new HTTP error by formating a message

func FromResponse

func FromResponse(r *http.Response) error

FromResponse creates a new HTTP error from a response

func InternalServerError

func InternalServerError(err error) error

InternalServerError creates an HTTP 500 error

func IsClientError

func IsClientError(code int) bool

IsClientError checks if code is HTTP client error

func IsError

func IsError(code int) bool

IsError checks if code is any HTTP error code

func IsInformational

func IsInformational(code int) bool

IsInformational checks if code is HTTP informational code

func IsRedirect

func IsRedirect(code int) bool

IsRedirect checks if code is HTTP redirect

func IsServerError

func IsServerError(code int) bool

IsServerError checks if code is HTTP server error

func IsSuccess

func IsSuccess(code int) bool

IsSuccess checks if code is HTTP success code

func MethodNotAllowed

func MethodNotAllowed(err error) error

MethodNotAllowed creates an HTTP 405 error

func New

func New(code int, err error) error

New creates a new HTTP error

func NotFound

func NotFound(err error) error

NotFound creates an HTTP 404 error

func RespondJSON

func RespondJSON(w http.ResponseWriter, x interface{}) error

RespondJSON sends a JSON encoded HTTP response

Types

type Response

type Response struct {
	Message    string `json:"message"`
	Error      string `json:"error"`
	StatusCode int    `json:"statusCode"`
}

Response is a response message

type StatusCoder

type StatusCoder interface {
	StatusCode() int
}

StatusCoder returns an HTTP status code

Jump to

Keyboard shortcuts

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