aboutsummaryrefslogtreecommitdiff
path: root/go/weed/master.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2013-12-01 14:41:47 -0800
committerChris Lu <chris.lu@gmail.com>2013-12-01 14:41:47 -0800
commitbc2f3b26e708636700af674e20ec0a8cc6dede6c (patch)
tree1ab18097679c98d8bd96adbb31a891ef74c5b94d /go/weed/master.go
parent1645d3c18534324de795643974299de0d512d3f1 (diff)
downloadseaweedfs-bc2f3b26e708636700af674e20ec0a8cc6dede6c.tar.xz
seaweedfs-bc2f3b26e708636700af674e20ec0a8cc6dede6c.zip
refactoring, start to use gorilla/mux
Diffstat (limited to 'go/weed/master.go')
-rw-r--r--go/weed/master.go22
1 files changed, 12 insertions, 10 deletions
diff --git a/go/weed/master.go b/go/weed/master.go
index 4fff9c2dd..6255f85f5 100644
--- a/go/weed/master.go
+++ b/go/weed/master.go
@@ -10,6 +10,7 @@ import (
"code.google.com/p/weed-fs/go/topology"
"encoding/json"
"errors"
+ "github.com/gorilla/mux"
"net/http"
"os"
"path"
@@ -233,23 +234,24 @@ func runMaster(cmd *Command, args []string) bool {
}
vg = replication.NewDefaultVolumeGrowth()
glog.V(0).Infoln("Volume Size Limit is", *volumeSizeLimitMB, "MB")
- http.HandleFunc("/dir/assign", secure(masterWhiteList, dirAssignHandler))
- http.HandleFunc("/dir/lookup", secure(masterWhiteList, dirLookupHandler))
- http.HandleFunc("/dir/join", secure(masterWhiteList, dirJoinHandler))
- http.HandleFunc("/dir/status", secure(masterWhiteList, dirStatusHandler))
- http.HandleFunc("/vol/grow", secure(masterWhiteList, volumeGrowHandler))
- http.HandleFunc("/vol/status", secure(masterWhiteList, volumeStatusHandler))
- http.HandleFunc("/vol/vacuum", secure(masterWhiteList, volumeVacuumHandler))
- http.HandleFunc("/submit", secure(masterWhiteList, submitFromMasterServerHandler))
- http.HandleFunc("/", redirectHandler)
+ r := mux.NewRouter()
+ r.HandleFunc("/dir/assign", secure(masterWhiteList, dirAssignHandler))
+ r.HandleFunc("/dir/lookup", secure(masterWhiteList, dirLookupHandler))
+ r.HandleFunc("/dir/join", secure(masterWhiteList, dirJoinHandler))
+ r.HandleFunc("/dir/status", secure(masterWhiteList, dirStatusHandler))
+ r.HandleFunc("/vol/grow", secure(masterWhiteList, volumeGrowHandler))
+ r.HandleFunc("/vol/status", secure(masterWhiteList, volumeStatusHandler))
+ r.HandleFunc("/vol/vacuum", secure(masterWhiteList, volumeVacuumHandler))
+ r.HandleFunc("/submit", secure(masterWhiteList, submitFromMasterServerHandler))
+ r.HandleFunc("/", redirectHandler)
topo.StartRefreshWritableVolumes(*garbageThreshold)
glog.V(0).Infoln("Start Weed Master", VERSION, "at port", strconv.Itoa(*mport))
srv := &http.Server{
Addr: ":" + strconv.Itoa(*mport),
- Handler: http.DefaultServeMux,
+ Handler: r,
ReadTimeout: time.Duration(*mReadTimeout) * time.Second,
}
e = srv.ListenAndServe()