middleware

package
v0.0.0-...-f94be1b Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	// Adapt adapts a handler to a given set of middleware in a
	// specific order. The request gets passed on to the next
	// middleware according to the order in which the handler is
	// adapted.
	Adapt(http.HandlerFunc, ...Middleware) http.HandlerFunc
}

Adapter is implemented by any value that has Adapt method. Adapter is a type that can 'adapt' a given handler to the set of middleware in a specific order.

type Chainer

type Chainer interface {
	// Wrap wraps a handler in a single middleware or a set of middleware.
	// The sequence of in which the handler is wrapped can be defined
	// manually or it can be defined by an Adapter.
	Wrap(http.HandlerFunc) http.HandlerFunc
}

Chainer is implemented by any value that has a Wrap method, which wraps a single middleware or a 'chain' of middleware on top of the given handler function and returns the resulting 'wrapped' handler function.

type Fifo

type Fifo string

Fifo is a type that implements Adapter. It provides a First-In, First-Out ordering of the middleware.

func (*Fifo) Adapt

func (f *Fifo) Adapt(h http.HandlerFunc, m ...Middleware) http.HandlerFunc

Adapt adapts the handler in First-In, First-Out manner. The request will pass through the middleware in the sequence in which they are passed in the function.

type Lifo

type Lifo string

Lifo is a type that implements Adapter. It provides a Last-In, First-Out ordering of the middleware.

func (*Lifo) Adapt

func (l *Lifo) Adapt(h http.HandlerFunc, m ...Middleware) http.HandlerFunc

Adapt adapts the handler in Last-In, First-Out manner. The request will pass through the middleware in the opposite sequence in which they are passed.

type Middleware

type Middleware func(http.HandlerFunc) http.HandlerFunc

Middleware is a type that represents a middleware function. A middleware usually operates on the request before and after the request is served.

type Single

type Single string

Single is a type that implements Adapter. It provides a simplest of ordering in which a handler is adapted to a single middleware. Embedding Single type makes it clear that a chain of middleware deals with only a single middleware.

func (*Single) Adapt

func (s *Single) Adapt(h http.HandlerFunc, m ...Middleware) http.HandlerFunc

Adapt adapts the handler to a single middleware.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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