httphelper

package
v0.0.0-...-5af0fa5 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2024 License: BSD-2-Clause Imports: 7 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DesiredContentTypeKey = "desiredContentType"
)

Variables

This section is empty.

Functions

func GetHTTPErrorCode

func GetHTTPErrorCode(err error) int

func MakeAPIHandler

func MakeAPIHandler(
	f func(r *http.Request) (resp interface{}, err error),
) func(w http.ResponseWriter, r *http.Request)

func MakeAPIHandlerWWriter

func MakeAPIHandlerWWriter(
	f func(w http.ResponseWriter, r *http.Request) (err error),
) func(w http.ResponseWriter, r *http.Request)

func MakeDesiredContentTypeMiddleware

func MakeDesiredContentTypeMiddleware(
	contentType string,
) func(inner http.Handler) http.Handler

func MakeForbiddenError

func MakeForbiddenError() error

func MakeInternalServerError

func MakeInternalServerError(intError error) error

func MakeInternalServerErrorf

func MakeInternalServerErrorf(
	intError error, format string, args ...interface{},
) error

MakeInternalServerErrorf returns internalServerError annotated with the formatted message, which does NOT wrap the original error, since we don't want internal server error details to percolate to clients.

func MakeNotImplementedError

func MakeNotImplementedError() error

func MakeUnauthorizedError

func MakeUnauthorizedError() error

func RespondWithError

func RespondWithError(w http.ResponseWriter, r *http.Request, errResp error)

Types

type ErrorResponse

type ErrorResponse struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
}

func GetErrorStruct

func GetErrorStruct(errResp error) *ErrorResponse

Jump to

Keyboard shortcuts

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