diff options
author | Emile <hanemile@protonmail.com> | 2019-02-07 02:45:33 +0100 |
---|---|---|
committer | Emile <hanemile@protonmail.com> | 2019-02-07 02:45:33 +0100 |
commit | d2d08cecf4746a53df305fb67468919ef9657836 (patch) | |
tree | 29b2823fc9137d9b6566f63a36091f62d62068e6 /export.go | |
parent | 515aeb56e414b4dc43a58171a93c3eaebdcd1906 (diff) |
new model, see the wiki for a description how this all works
Diffstat (limited to 'export.go')
-rw-r--r-- | export.go | 40 |
1 files changed, 0 insertions, 40 deletions
diff --git a/export.go b/export.go deleted file mode 100644 index 9cc67af..0000000 --- a/export.go +++ /dev/null @@ -1,40 +0,0 @@ -package main - -import ( - "encoding/json" - "fmt" - "io/ioutil" - "net/http" - "strconv" - - "github.com/gorilla/mux" -) - -// export exports all the trees -func export(treeindex int64) error { - // Convert the data to json - jsonData, jsonMarshalerError := json.Marshal(treeArray[treeindex]) - if jsonMarshalerError != nil { - panic(jsonMarshalerError) - } - - // write the json formatted byte data to a file - err := ioutil.WriteFile(fmt.Sprintf("/exports/tree_%d.json", treeindex), jsonData, 0644) - if err != nil { - return err - } - return nil -} - -// export the selected tree to the selected file -func exportHandler(w http.ResponseWriter, r *http.Request) { - vars := mux.Vars(r) - treeindex, _ := strconv.ParseInt(vars["treeindex"], 10, 0) - - err := export(treeindex) - if err != nil { - panic(err) - } - - _, _ = fmt.Fprintf(w, "Exportet Tree %d", treeindex) -} |