예제 #1
0
func (r Router) Mux() *mux.Router {
	rtr := new(mux.Router)

	for _, rs := range r.Routables {
		rtr.HandleFunc(rs.Route(), rs.Handler())
	}

	return rtr
}
예제 #2
0
파일: rain.go 프로젝트: zeebo/gorain
//Setup dat http
func main() {
	var err os.Error
	session, err = mgo.Mongo(mgoUrl)
	if err != nil {
		panic(err)
	}

	router := new(mux.Router)
	router.HandleFunc("/a", w(announce)) //dont support scrapes
	router.HandleFunc("/ping", w(ping))
	if err := http.ListenAndServe(":9988", router); err != nil {
		log.Fatal(err)
	}
}
예제 #3
0
파일: main.go 프로젝트: cmars/replican-web
func main() {
	if len(os.Args) < 2 {
		fmt.Fprintf(os.Stderr, "Usage: %s <path>\n", os.Args[0])
		os.Exit(1)
	}

	local, err := fs.NewLocalStore(os.Args[1])
	if err != nil {
		fmt.Fprintf(os.Stderr, "%s\n", err.String())
		os.Exit(1)
	}

	var router = new(mux.Router)
	router.HandleFunc(fmt.Sprintf("/%s", web.NODEROOT), srv.TreeHandler(local))
	router.HandleFunc(fmt.Sprintf("/%s/{strong}", web.BLOCKS), srv.BlockHandler(local))
	router.HandleFunc(fmt.Sprintf("/%s/{strong}/{offset}/{length}", web.FILES),
		srv.FileHandler(local))

	http.Handle("/", router)
	http.ListenAndServe(":8080", nil)
}