webhandlers

package
v3.24.0 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2023 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Template = func() *ErrorTemplate {
	return NewErrorTemplate(template.Must(template.New("error").Parse(errorTemplate)))
}()

Template for rendering the static error.

Functions

func Error

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

Error writes the error to the response writer.

func JSON added in v3.16.2

func JSON(w http.ResponseWriter, r *http.Request, i interface{})

JSON encodes the provided message as JSON. When a marshalling error is encountered, Error is used in order to handle the error.

func NewContextWithErrorValue

func NewContextWithErrorValue(parent context.Context) (ctx context.Context, getError func() error)

NewContextWithErrorValue returns a context derived from parent and a func that returns any error stored by the Error handler.

func NotFound

func NotFound(w http.ResponseWriter, r *http.Request)

NotFound is the handler for routes that could not be found.

func ProcessError added in v3.16.2

func ProcessError(in error) (statusCode int, err error)

ProcessError processes an HTTP error by converting it if appropriate, and determining the HTTP status code to return.

func RetrieveError added in v3.16.2

func RetrieveError(r *http.Request) error

RetrieveError retrieves the error from the context.

func WithErrorHandlers added in v3.16.2

func WithErrorHandlers(h map[string]http.Handler) func(http.Handler) http.Handler

WithErrorHandlers registers additional error handlers to be used while rendering errors.

Types

type Data added in v3.16.2

type Data struct {
	ErrorTitle          string
	ErrorMessage        string
	ErrorID             string
	CorrelationID       string
	BackendErrorDetails string
	Year                int
	IsGenericNotFound   bool
}

Data contains data to render templates.

type ErrorTemplate added in v3.16.2

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

ErrorTemplate wraps the error template for the static error route.

func NewErrorTemplate added in v3.16.2

func NewErrorTemplate(t *template.Template) *ErrorTemplate

NewErrorTemplate instantiates a new error template for non-frontend handled routes.

func (*ErrorTemplate) ServeHTTP added in v3.16.2

func (t *ErrorTemplate) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP renders the non-frontend handled errors.

Jump to

Keyboard shortcuts

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