func (mux *Mux) Handle(ctx *Context, res *http.Response, err error) {
	mux.mu.RLock()
	defer mux.mu.RUnlock()
	if err != nil {
		if h, ok := mux.errm[err]; ok {
			h.Handle(ctx, res, err)
			return
		}
		if h, ok := mux.errm[nil]; ok {
			h.Handle(ctx, res, err)
			return
		}
	} else {
		var h Handler
		var n = -1
		for r := range mux.res {
			if ok, cnt := r.match(res); ok {
				if cnt > n {
					h, n = r.h, cnt
				}
			}
		}
		if h != nil {
			h.Handle(ctx, res, err)
			return
		}
	}
	mux.DefaultHandler.Handle(ctx, res, err)
}
Handle is the Handler interface implementation for Mux. It dispatches the calls
to the matching Handler.
package fetchbot
import (
	"net/http"
	"strings"
	"sync"
)
type Context struct {
	Cmd Command
	Q   *Queue
}
type Handler interface {
	Handle(*Context, *http.Response, error)
}
type HandlerFunc func(*Context, *http.Response, error)
func (h HandlerFunc) Handle(ctx *Context, res *http.Response, err error) {
	h(ctx, res, err)
}
type Mux struct {
	DefaultHandler Handler
	mu   sync.RWMutex
	errm map[error]Handler
	res  map[*ResponseMatcher]bool  
}
func NewMux() *Mux {
	return &Mux{
		DefaultHandler: HandlerFunc(func(ctx *Context, res *http.Response, err error) {}),
		errm:           make(map[error]Handler),
		res:            make(map[*ResponseMatcher]bool),
	}
}