errors

package
v0.40.7 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2024 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDoesNotMatchWhen = ErrHandlerNotResponsible
View Source
var ErrErrorHandlerNotEnabled = herodot.DefaultError{
	ErrorField:  "error handler matching this route is misconfigured or disabled",
	CodeField:   http.StatusInternalServerError,
	StatusField: http.StatusText(http.StatusInternalServerError),
}
View Source
var ErrHandlerNotResponsible = errors.New("error handler not responsible for this request")

Functions

func MatchesWhen

func MatchesWhen(whens Whens, r *http.Request, err error) error

func NewErrErrorHandlerMisconfigured

func NewErrErrorHandlerMisconfigured(a Handler, err error) *herodot.DefaultError

func NewErrErrorHandlerNotEnabled

func NewErrErrorHandlerNotEnabled(a Handler) *herodot.DefaultError

Types

type ErrorJSON

type ErrorJSON struct {
	// contains filtered or unexported fields
}

func NewErrorJSON

func NewErrorJSON(
	c configuration.Provider,
	d errorJSONDependencies,
) *ErrorJSON

func (*ErrorJSON) Config

func (a *ErrorJSON) Config(config json.RawMessage) (*ErrorJSONConfig, error)

func (*ErrorJSON) GetID

func (a *ErrorJSON) GetID() string

func (*ErrorJSON) Handle

func (a *ErrorJSON) Handle(w http.ResponseWriter, r *http.Request, config json.RawMessage, _ pipeline.Rule, handleError error) error

func (*ErrorJSON) Validate

func (a *ErrorJSON) Validate(config json.RawMessage) error

type ErrorJSONConfig

type ErrorJSONConfig struct {
	Verbose bool `json:"verbose"`
}

type ErrorRedirect

type ErrorRedirect struct {
	// contains filtered or unexported fields
}

func (*ErrorRedirect) Config

func (a *ErrorRedirect) Config(config json.RawMessage) (*ErrorRedirectConfig, error)

func (*ErrorRedirect) GetID

func (a *ErrorRedirect) GetID() string

func (*ErrorRedirect) Handle

func (*ErrorRedirect) RedirectURL

func (a *ErrorRedirect) RedirectURL(uri *url.URL, c *ErrorRedirectConfig) string

func (*ErrorRedirect) Validate

func (a *ErrorRedirect) Validate(config json.RawMessage) error

type ErrorRedirectConfig

type ErrorRedirectConfig struct {
	To                 string `json:"to"`
	Code               int    `json:"code"`
	ReturnToQueryParam string `json:"return_to_query_param"`
}

type ErrorRedirectDependencies

type ErrorRedirectDependencies interface {
	x.RegistryWriter
}

type ErrorWWWAuthenticate

type ErrorWWWAuthenticate struct {
	// contains filtered or unexported fields
}

func (*ErrorWWWAuthenticate) Config

func (*ErrorWWWAuthenticate) GetID

func (a *ErrorWWWAuthenticate) GetID() string

func (*ErrorWWWAuthenticate) Handle

func (*ErrorWWWAuthenticate) Validate

func (a *ErrorWWWAuthenticate) Validate(config json.RawMessage) error

type ErrorWWWAuthenticateConfig

type ErrorWWWAuthenticateConfig struct {
	Realm string `json:"realm"`
}

type ErrorWWWAuthenticateDependencies

type ErrorWWWAuthenticateDependencies interface {
	x.RegistryWriter
}

type Handler

type Handler interface {
	GetID() string
	Handle(w http.ResponseWriter, r *http.Request, config json.RawMessage, _ pipeline.Rule, err error) error
	Validate(config json.RawMessage) error
}

type Handlers

type Handlers []Handler

func (Handlers) IDs

func (h Handlers) IDs() (res []string)

type Registry

type Registry interface {
	AvailablePipelineErrorHandlers() Handlers
	PipelineErrorHandler(id string) (Handler, error)
}

type When

type When struct {
	Error   []string     `json:"error"`
	Request *WhenRequest `json:"request"`
}

type WhenRequest

type WhenRequest struct {
	RemoteIP *WhenRequestRemoteIP `json:"remote_ip"`
	Header   *WhenRequestHeader   `json:"header"`
}

type WhenRequestHeader

type WhenRequestHeader struct {
	ContentType []string `json:"content_type"`
	Accept      []string `json:"accept"`
}

type WhenRequestRemoteIP

type WhenRequestRemoteIP struct {
	Match                     []string `json:"match"`
	RespectForwardedForHeader bool     `json:"respect_forwarded_for_header"`
}

type Whens

type Whens []When

Jump to

Keyboard shortcuts

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