jsrest

package module
v0.0.0-...-e18710a Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2023 License: Apache-2.0 Imports: 7 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadRequest                   = NewHTTPError(http.StatusBadRequest)
	ErrUnauthorized                 = NewHTTPError(http.StatusUnauthorized)
	ErrPaymentRequired              = NewHTTPError(http.StatusPaymentRequired)
	ErrForbidden                    = NewHTTPError(http.StatusForbidden)
	ErrNotFound                     = NewHTTPError(http.StatusNotFound)
	ErrMethodNotAllowed             = NewHTTPError(http.StatusMethodNotAllowed)
	ErrNotAcceptable                = NewHTTPError(http.StatusNotAcceptable)
	ErrProxyAuthRequired            = NewHTTPError(http.StatusProxyAuthRequired)
	ErrRequestTimeout               = NewHTTPError(http.StatusRequestTimeout)
	ErrConflict                     = NewHTTPError(http.StatusConflict)
	ErrGone                         = NewHTTPError(http.StatusGone)
	ErrLengthRequired               = NewHTTPError(http.StatusLengthRequired)
	ErrPreconditionFailed           = NewHTTPError(http.StatusPreconditionFailed)
	ErrRequestEntityTooLarge        = NewHTTPError(http.StatusRequestEntityTooLarge)
	ErrRequestURITooLong            = NewHTTPError(http.StatusRequestURITooLong)
	ErrUnsupportedMediaType         = NewHTTPError(http.StatusUnsupportedMediaType)
	ErrRequestedRangeNotSatisfiable = NewHTTPError(http.StatusRequestedRangeNotSatisfiable)
	ErrExpectationFailed            = NewHTTPError(http.StatusExpectationFailed)
	ErrTeapot                       = NewHTTPError(http.StatusTeapot)
	ErrMisdirectedRequest           = NewHTTPError(http.StatusMisdirectedRequest)
	ErrUnprocessableEntity          = NewHTTPError(http.StatusUnprocessableEntity)
	ErrLocked                       = NewHTTPError(http.StatusLocked)
	ErrFailedDependency             = NewHTTPError(http.StatusFailedDependency)
	ErrTooEarly                     = NewHTTPError(http.StatusTooEarly)
	ErrUpgradeRequired              = NewHTTPError(http.StatusUpgradeRequired)
	ErrPreconditionRequired         = NewHTTPError(http.StatusPreconditionRequired)
	ErrTooManyRequests              = NewHTTPError(http.StatusTooManyRequests)
	ErrRequestHeaderFieldsTooLarge  = NewHTTPError(http.StatusRequestHeaderFieldsTooLarge)
	ErrUnavailableForLegalReasons   = NewHTTPError(http.StatusUnavailableForLegalReasons)

	ErrInternalServerError           = NewHTTPError(http.StatusInternalServerError)
	ErrNotImplemented                = NewHTTPError(http.StatusNotImplemented)
	ErrBadGateway                    = NewHTTPError(http.StatusBadGateway)
	ErrServiceUnavailable            = NewHTTPError(http.StatusServiceUnavailable)
	ErrGatewayTimeout                = NewHTTPError(http.StatusGatewayTimeout)
	ErrHTTPVersionNotSupported       = NewHTTPError(http.StatusHTTPVersionNotSupported)
	ErrVariantAlsoNegotiates         = NewHTTPError(http.StatusVariantAlsoNegotiates)
	ErrInsufficientStorage           = NewHTTPError(http.StatusInsufficientStorage)
	ErrLoopDetected                  = NewHTTPError(http.StatusLoopDetected)
	ErrNotExtended                   = NewHTTPError(http.StatusNotExtended)
	ErrNetworkAuthenticationRequired = NewHTTPError(http.StatusNetworkAuthenticationRequired)
)
View Source
var ErrUnsupportedContentType = errors.New("unsupported Content-Type")

Functions

func Errorf

func Errorf(he *HTTPError, format string, a ...any) error

func Read

func Read(r *http.Request, obj any) error

func ReadError

func ReadError(resp *resty.Response) error

func Write

func Write(w http.ResponseWriter, obj any) error

func WriteError

func WriteError(w http.ResponseWriter, err error)

func WriteList

func WriteList(w http.ResponseWriter, list []any, etag string) error

Types

type HTTPError

type HTTPError struct {
	Code    int
	Message string
}

func GetHTTPError

func GetHTTPError(err error) *HTTPError

func NewHTTPError

func NewHTTPError(code int) *HTTPError

func (*HTTPError) Error

func (err *HTTPError) Error() string

type JSONError

type JSONError struct {
	Code     int      `json:"-"`
	Messages []string `json:"messages"`
}

func ToJSONError

func ToJSONError(err error) *JSONError

func (*JSONError) Error

func (je *JSONError) Error() string

func (*JSONError) Unwrap

func (je *JSONError) Unwrap() error

type SilentJoinError

type SilentJoinError struct {
	Wraps []error
}

func SilentJoin

func SilentJoin(errs ...error) *SilentJoinError

func (*SilentJoinError) Error

func (err *SilentJoinError) Error() string

func (*SilentJoinError) Unwrap

func (err *SilentJoinError) Unwrap() []error

Jump to

Keyboard shortcuts

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