func (self *server) Connect(pattern string, handler interface{}) {
	self.register(pattern, handler, "CONNECT")
}
Connect is a shortcut for mux.HandleFunc(pattern, handler).Methods("CONNECT")
it also fetch the full function name of the handler (with package) to name the route.
package rex
import (
	"flag"
	"fmt"
	"net/http"
	"path/filepath"
	"runtime"
	"strings"
	"sync"
	"time"
	log "github.com/Sirupsen/logrus"
	"github.com/goanywhere/env"
	"github.com/gorilla/mux"
)
var (
	debug    bool
	port     int
	maxprocs int
	once sync.Once
)
type server struct {
	middleware *middleware
	mux        *mux.Router
	ready      bool
	subservers []*server
}
func New() *server {
	self := &server{
		middleware: new(middleware),
		mux:        mux.NewRouter().StrictSlash(true),
	}
	self.configure()
	return self
}
func (self *server) configure() {
	once.Do(func() {
		flag.BoolVar(&debug, "debug", env.Bool("DEBUG", true), "flag to toggle debug mode")
		flag.IntVar(&port, "port", env.Int("PORT", 5000), "port to run the application server")
		flag.IntVar(&maxprocs, "maxprocs", env.Int("MAXPROCS", runtime.NumCPU()), "maximum cpu processes to run the server")
		flag.Parse()
	})
}
func (self *server) build() http.Handler {
	if !self.ready {
		self.Use(func(http.Handler) http.Handler {
			return self.mux
		})
		for index := 0; index < len(self.subservers); index++ {
			server := self.subservers[index]
			server.Use(func(http.Handler) http.Handler {
				return server.mux
			})
		}
		self.ready = true
	}
	return self.middleware
}
func (self *server) register(pattern string, handler interface{}, methods ...string) {
	var name = strings.Join(methods, "|") + ":" + pattern
	switch H := handler.(type) {
	case http.Handler:
		self.mux.Handle(pattern, H).Methods(methods...).Name(name)
	case func(http.ResponseWriter, *http.Request):
		self.mux.HandleFunc(pattern, H).Methods(methods...).Name(name)
	default:
		panic("Unsupported handler: " + name)
	}
}
func (self *server) Any(pattern string, handler interface{}) {
	self.register(pattern, handler, "GET", "POST", "PUT", "DELETE", "OPTIONS", "HEAD")
}
func (self *server) Group(prefix string) *server {
	var middleware = new(middleware)
	self.mux.PathPrefix(prefix).Handler(middleware)
	var mux = self.mux.PathPrefix(prefix).Subrouter()
	server := &server{middleware: middleware, mux: mux}
	self.subservers = append(self.subservers, server)
	return server
}
func (self *server) Host(domain string) *server {
	var middleware = new(middleware)
  self.mux.Host(domain).Handler(middleware)
  var mux = self.mux.Host(domain).Subrouter()
	server := &server{middleware: middleware, mux: mux}
	self.subservers = append(self.subservers, server)
	return server
}
func (self *server) Name(r *http.Request) (name string) {
	var match mux.RouteMatch
	if self.mux.Match(r, &match) {
		name = match.Route.GetName()
	}
	return name
}
func (self *server) FileServer(prefix, dir string) {
	if abs, err := filepath.Abs(dir); err == nil {
		fs := http.StripPrefix(prefix, http.FileServer(http.Dir(abs)))
		self.mux.PathPrefix(prefix).Handler(fs)
	} else {
		panic("Failed to setup file server: " + err.Error())
	}
}
func (self *server) Use(modules ...func(http.Handler) http.Handler) {
	self.middleware.stack = append(self.middleware.stack, modules...)
}
func (self *server) Get(pattern string, handler interface{}) {
	self.register(pattern, handler, "GET")
}
func (self *server) Head(pattern string, handler interface{}) {
	self.register(pattern, handler, "HEAD")
}
func (self *server) Options(pattern string, handler interface{}) {
	self.register(pattern, handler, "OPTIONS")
}
func (self *server) Post(pattern string, handler interface{}) {
	self.register(pattern, handler, "POST")
}
func (self *server) Put(pattern string, handler interface{}) {
	self.register(pattern, handler, "PUT")
}
func (self *server) Delete(pattern string, handler interface{}) {
	self.register(pattern, handler, "DELETE")
}
func (self *server) Trace(pattern string, handler interface{}) {
	self.register(pattern, handler, "TRACE")
}