web

package
v0.0.0-...-5352646 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package web implements a middleware to handle HTTP errors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorMiddleware

func ErrorMiddleware(extraRenderers map[string]ErrorRenderer) echo.MiddlewareFunc

ErrorMiddleware returns an Echo middleware that catches errors in the chain, and renders them using the negotiated renderer. Global renderers can be registered with RegisterRenderer, and extra renderers can be passed to this function.

func ProcessError

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 RegisterRenderer

func RegisterRenderer(contentType string, renderer ErrorRenderer)

RegisterRenderer registers a global error renderer.

Types

type ErrorRenderer

type ErrorRenderer interface {
	RenderError(c echo.Context, statusCode int, err error) error
}

ErrorRenderer is an interface for rendering errors to HTTP responses.

type ErrorRendererFunc

type ErrorRendererFunc func(c echo.Context, statusCode int, err error) error

ErrorRendererFunc is a function signature that implements ErrorRenderer.

func (ErrorRendererFunc) RenderError

func (f ErrorRendererFunc) RenderError(c echo.Context, statusCode int, err error) error

RenderError implements the ErrorRenderer interface.

Jump to

Keyboard shortcuts

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