middleware

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: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrHTTPRecovered = errors.DefineInternal("http_recovered", "Internal Server Error")

ErrHTTPRecovered is returned when a panic is caught from an HTTP handler.

Functions

func FillContext

func FillContext(fillers ...fillcontext.Filler) echo.MiddlewareFunc

FillContext fills the request context by executing the given fillers.

func ID

func ID(prefix string) echo.MiddlewareFunc

ID adds a request id to the request.

func Immutable

func Immutable(next echo.HandlerFunc) echo.HandlerFunc

Immutable set the Cache-Control header to make the resource immutable. This means the client will never try to revalidate the resource.

func Log

func Log(logger log.Interface) echo.MiddlewareFunc

Log is middleware that logs the request.

func Noop

func Noop(next echo.HandlerFunc) echo.HandlerFunc

Noop is middleware that does nothing.

func Normalize

func Normalize(mode NormalizationMode) echo.MiddlewareFunc

Normalize is middleware that normalizes the url and redirects the request if necessary.

func Recover

func Recover() echo.MiddlewareFunc

Recover returns Echo middleware that recovers from panics.

func RedirectToHTTPS

func RedirectToHTTPS(fromToPorts map[int]int) echo.MiddlewareFunc

RedirectToHTTPS redirects requests from HTTP to HTTPS.

func RedirectToHost

func RedirectToHost(target string) echo.MiddlewareFunc

RedirectToHost redirects to the target host if not already used. The port of the request is preserved.

Types

type NormalizationMode

type NormalizationMode int

NormalizationMode describes how to normalize the request url.

const (
	// Ignore is the normalization mode where no action is taken.
	Ignore NormalizationMode = iota

	// RedirectPermanent is the normalization mode where the client is redirected with 301 or 308.
	RedirectPermanent

	// RedirectTemporary is the normalization mode where the client is redirected with 302 or 307.
	RedirectTemporary

	// Continue is the normalization mode where the request url is updated but the request can just be handled.
	Continue
)

Jump to

Keyboard shortcuts

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