aboutsummaryrefslogtreecommitdiff
path: root/weed-fs
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2012-10-09 21:06:24 -0700
committerChris Lu <chris.lu@gmail.com>2012-10-09 21:06:24 -0700
commitce615b4e6f5b8d76e5bd76c33042b454b24082f4 (patch)
tree2cad1ac6a10e1b14161d7f34b94078450e63b928 /weed-fs
parent6b1e60582c20a36e5b8e76b47d3fc0510bc99c9c (diff)
downloadseaweedfs-ce615b4e6f5b8d76e5bd76c33042b454b24082f4.tar.xz
seaweedfs-ce615b4e6f5b8d76e5bd76c33042b454b24082f4.zip
setting http status code for failed requests
Diffstat (limited to 'weed-fs')
-rw-r--r--weed-fs/src/cmd/weed/master.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/weed-fs/src/cmd/weed/master.go b/weed-fs/src/cmd/weed/master.go
index 9ad99f128..d9418daa4 100644
--- a/weed-fs/src/cmd/weed/master.go
+++ b/weed-fs/src/cmd/weed/master.go
@@ -58,8 +58,12 @@ func dirLookupHandler(w http.ResponseWriter, r *http.Request) {
}
writeJson(w, r, map[string]interface{}{"locations": ret})
} else {
+ w.WriteHeader(http.StatusNotFound)
writeJson(w, r, map[string]string{"error": "volume id " + volumeId.String() + " not found. "})
}
+ } else {
+ w.WriteHeader(http.StatusNotAcceptable)
+ writeJson(w, r, map[string]string{"error": "unknown volumeId format " + vid})
}
}
@@ -74,11 +78,13 @@ func dirAssignHandler(w http.ResponseWriter, r *http.Request) {
}
rt, err := storage.NewReplicationTypeFromString(repType)
if err != nil {
+ w.WriteHeader(http.StatusNotAcceptable)
writeJson(w, r, map[string]string{"error": err.Error()})
return
}
if topo.GetVolumeLayout(rt).GetActiveVolumeCount() <= 0 {
if topo.FreeSpace() <= 0 {
+ w.WriteHeader(http.StatusNotFound)
writeJson(w, r, map[string]string{"error": "No free volumes left!"})
return
} else {
@@ -89,6 +95,7 @@ func dirAssignHandler(w http.ResponseWriter, r *http.Request) {
if err == nil {
writeJson(w, r, map[string]interface{}{"fid": fid, "url": dn.Url(), "publicUrl": dn.PublicUrl, "count": count})
} else {
+ w.WriteHeader(http.StatusNotAcceptable)
writeJson(w, r, map[string]string{"error": err.Error()})
}
}
@@ -128,6 +135,7 @@ func volumeGrowHandler(w http.ResponseWriter, r *http.Request) {
}
}
if err != nil {
+ w.WriteHeader(http.StatusNotAcceptable)
writeJson(w, r, map[string]string{"error": err.Error()})
} else {
writeJson(w, r, map[string]interface{}{"count": count})