Back to godoc.org

Package middleware

v0.0.0-...-c44bc7d
Latest Go to latest

The highest tagged major version is v3.

Published: Feb 6, 2020 | License: Apache-2.0 | Module: go.thethings.network/lorawan-stack

Index

Variables

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

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

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.

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
)

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier