filters

package
v0.0.0-...-8b1022e Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2016 License: Apache-2.0, Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fail

func Fail(msg string, args ...interface{}) error

Fail fails execution of the current chain

func Stop

func Stop() error

Stop stops execution of the current chain

Types

type Chain

type Chain []Filter

Chain is a chain of Filters that acts as an http.Handler.

func Join

func Join(filters ...Filter) Chain

Join constructs a new chain of filters that executes the filters in order until it encounters a filter that returns false.

func (Chain) Append

func (c Chain) Append(post ...Filter) Chain

Append creates a new Chain by appending the given filters.

func (Chain) Prepend

func (c Chain) Prepend(pre Filter) Chain

Prepend creates a new chain by prepending the given filter.

func (Chain) ServeHTTP

func (c Chain) ServeHTTP(w http.ResponseWriter, req *http.Request)

type Filter

type Filter interface {
	// Apply is like the function on http.Handler but also gets a Next which
	// allows it to continue execution along the current filter chain. If Apply
	// returns an error, we will write an appropriate status code to the response.
	// Tip - use filters.Fail() to provide an error with a description.
	Apply(w http.ResponseWriter, req *http.Request, next Next) error
}

Filter is like an http.Handler that

func Adapt

func Adapt(handler http.Handler) Filter

Adapt adapts an existing http.Handler to the Filter interface.

type Next

type Next func() error

Next is an interface for calling the next Filter in the chain.

Jump to

Keyboard shortcuts

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