// The block get Func retrieves a block given a range // Parameters are // start (optional) the start block (inclusive) // end (optional) the end block (inclusive) // tag (optional) the tag of the version to do this for // Basically the function retrieves the route given the tag version (or default root) // and then filters the block names given the start and end. // The return data is a list structure containing the key (block name) and the value (the value of the block) func blockGetFunc(w http.ResponseWriter, r *http.Request, filesys *fs.RootFileSystem) { fileNode, dirNode, err := filesys.GetFileOrDirectory(r.URL.Path, false) if err != nil { writeError(w, err) } else if dirNode != nil { writeError(w, errors.New("Cannot do this to a directory")) } else { // We have a filenode... blockStructure, err := filesys.GetBlock(fileNode, getFormValue(r, "tag", ""), getFormValue(r, "start", ""), getFormValue(r, "end", "")) if err != nil { writeError(w, err) } else { var b []byte b, err = json.MarshalIndent(blockStructure, "", " ") fmt.Fprintf(w, "%v", string(b)) } } }