|
|
@ -18,6 +18,7 @@ var ( |
|
|
|
chunkCount = flag.Int("chunks", 5, "data chunks to store files") |
|
|
|
publicServer = flag.String("pserver", "localhost:8080", "public server to serve data read") |
|
|
|
metaServer = flag.String("mserver", "localhost:9333", "metadata server to store mappings") |
|
|
|
IsDebug = flag.Bool("debug", false, "enable debug mode") |
|
|
|
|
|
|
|
store *storage.Store |
|
|
|
) |
|
|
@ -52,6 +53,9 @@ func GetHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
volumeId, _ := strconv.Atoui64(path[sepIndex+1 : commaIndex]) |
|
|
|
n.ParsePath(fid) |
|
|
|
|
|
|
|
if *IsDebug { |
|
|
|
log.Println("volume", volumeId, "reading", n) |
|
|
|
} |
|
|
|
store.Read(volumeId, n) |
|
|
|
if dotIndex > 0 { |
|
|
|
ext := path[dotIndex:] |
|
|
@ -67,8 +71,10 @@ func PostHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
if e != nil { |
|
|
|
writeJson(w, r, e) |
|
|
|
} else { |
|
|
|
store.Write(volumeId, storage.NewNeedle(r)) |
|
|
|
writeJson(w, r, make(map[string]string)) |
|
|
|
ret := store.Write(volumeId, storage.NewNeedle(r)) |
|
|
|
m := make(map[string]uint32) |
|
|
|
m["size"] = ret |
|
|
|
writeJson(w, r, m) |
|
|
|
} |
|
|
|
} |
|
|
|
func DeleteHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|