ion: github.com/estebarb/ion/components/chain Index | Files

package chain

import "github.com/estebarb/ion/components/chain"

Package chain provides functions for managing chains of middleware that can be used to provide reusable functionality that wraps http Handlers.

Index

Package Files

chain.go

func Sequence Uses

func Sequence(handlers ...http.Handler) http.Handler

Sequence returns a Handler that calls in order each handler passed as argument

type Chain Uses

type Chain struct {
    // contains filtered or unexported fields
}

Chain contains a list of Middleware that will wrap a handler

func Join Uses

func Join(chains ...*Chain) *Chain

Join merges several chains into a single one

func New Uses

func New() *Chain

New allocates a new Chain

func (*Chain) Add Uses

func (m *Chain) Add(h Middleware) *Chain

Add appents a middleware to the end of a Chain

func (*Chain) Then Uses

func (m *Chain) Then(h http.Handler) http.Handler

Then wraps a Handler with the middleware in the chain and returns the wrapped handler

func (*Chain) ThenFunc Uses

func (m *Chain) ThenFunc(h http.HandlerFunc) http.Handler

ThenFunc wraps a HandlerFunc with the middleware in the chain and returns the wrapped handler

type Middleware Uses

type Middleware func(next http.Handler) http.Handler

Middleware is a function that wraps an http.Handler

Package chain imports 1 packages (graph) and is imported by 1 packages. Updated 2017-01-10. Refresh now. Tools for package owners.