httperrors

package
v0.1.44 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2024 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorHandler

func ErrorHandler(w http.ResponseWriter, err HTTPError)

ErrorHandler is a helper function to write HTTPError to http.ResponseWriter

Types

type HTTPError

type HTTPError interface {
	Error() string
	StatusCode() int
}

HTTPError represents a generic HTTP error

func BadRequest

func BadRequest(message string) HTTPError

BadRequest creates a new 400 Bad Request error

func Forbidden

func Forbidden(message string) HTTPError

Forbidden creates a new 403 Forbidden error

func InternalServerError

func InternalServerError(message string) HTTPError

InternalServerError creates a new 500 Internal Server Error

func TooManyRequests

func TooManyRequests(message string) HTTPError

TooManyRequests creates a new 429 Too Many Requests error

func Unauthorized

func Unauthorized(message string) HTTPError

Unauthorized creates a new 401 Unauthorized error

Jump to

Keyboard shortcuts

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