From d2d08cecf4746a53df305fb67468919ef9657836 Mon Sep 17 00:00:00 2001 From: Emile Date: Thu, 7 Feb 2019 02:45:33 +0100 Subject: new model, see the wiki for a description how this all works --- export.go | 40 ---------------------------------------- 1 file changed, 40 deletions(-) delete mode 100644 export.go (limited to 'export.go') 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) -} -- cgit 1.4.1