muxchain: github.com/stephens2424/muxchain Index | Files | Directories

package muxchain

import "github.com/stephens2424/muxchain"

Index

Package Files

muxchain.go

Variables

var Default = &MuxChain{}

func Chain Uses

func Chain(pattern string, handlers ...http.Handler)

Chain registers the pattern and http.Handler chain to the DefaultMuxChain.

func ChainHandlers Uses

func ChainHandlers(handlers ...http.Handler) http.Handler

ChainHandlers chains together a set of handlers under an empty path.

func HandleChain Uses

func HandleChain(w http.ResponseWriter, req *http.Request, handlers ...http.Handler)

HandleChain is the utility function chained handlers are responsible for calling when they are complete.

type ChainedHandler Uses

type ChainedHandler interface {
    http.Handler

    // ServeHTTPChain allows the handler to do its work and then call the remaining
    // handler chain. Implementers should call muxchain.HandleChain when complete.
    ServeHTTPChain(w http.ResponseWriter, req *http.Request, h ...http.Handler)
}

ChainedHander allows implementers to call the handlers after them in a muxchain on their own. This allows handlers to defer functions until after the handler chain following them has been completed.

type ChainedHandlerFunc Uses

type ChainedHandlerFunc func(w http.ResponseWriter, req *http.Request, handlers ...http.Handler)

ChainedHandlerFunc represents a handler that is able to be chained to subsequent handlers.

func (ChainedHandlerFunc) ServeHTTP Uses

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

ServeHTTP allows ChainedHandlerFuncs to implement http.Handler

func (ChainedHandlerFunc) ServeHTTPChain Uses

func (c ChainedHandlerFunc) ServeHTTPChain(w http.ResponseWriter, req *http.Request, handlers ...http.Handler)

ServeHTTPChain allows ChainedHandlerFuncs to be identified

type CheckedResponseWriter Uses

type CheckedResponseWriter interface {
    http.ResponseWriter
    Written() bool
}

CheckedResponseWriter augments http.ResponseWriter to indicate if the response has been written to.

type MuxChain Uses

type MuxChain struct {
    Muxer
}

func (*MuxChain) Chain Uses

func (m *MuxChain) Chain(pattern string, handlers ...http.Handler)

Chain registers a pattern to a sequence of http.Handlers. Upon receiving a request, the mux chain will find the best matching pattern and call that chain of handlers. The handlers will be called in turn until one of them writes a response or the end of the chain is reached. If one of the handlers is a Muxer (e.g. http.ServeMux), the MuxChain will skip it if no pattern matches.

func (*MuxChain) ServeHTTPChain Uses

func (m *MuxChain) ServeHTTPChain(w http.ResponseWriter, req *http.Request, handlers ...http.Handler)

type Muxer Uses

type Muxer interface {
    http.Handler
    Handle(pattern string, handler http.Handler)
    Handler(r *http.Request) (h http.Handler, pattern string)
    HandleFunc(pattern string, handler func(http.ResponseWriter, *http.Request))
}

Muxer identifies types that act as a ServeMux.

Directories

PathSynopsis
muxchainutil
sample

Package muxchain imports 1 packages (graph) and is imported by 2 packages. Updated 2016-07-19. Refresh now. Tools for package owners.