From 63b337332575256131184d19e2208bba326c426c Mon Sep 17 00:00:00 2001 From: Emile Date: Sun, 10 Feb 2019 17:08:55 +0100 Subject: implemented the updateTotalMass function --- main.go | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/main.go b/main.go index 88db9a4..37586a6 100644 --- a/main.go +++ b/main.go @@ -132,6 +132,21 @@ func getListOfStarsCsvHandler(w http.ResponseWriter, r *http.Request) { } } +func updateTotalMassHandler(w http.ResponseWriter, r *http.Request) { + log.Println("[ ] The updateTotalMassHandler was accessed") + + // get the star by parsing http-post parameters + errParseForm := r.ParseForm() // parse the POST form + if errParseForm != nil { // handle errors + panic(errParseForm) + } + + // get the tree into which the star should be inserted into + index, _ := strconv.ParseInt(r.Form.Get("index"), 10, 64) + + updateTotalMassEndpoint(index) +} + func main() { router := mux.NewRouter() @@ -145,16 +160,12 @@ func main() { router.HandleFunc("/insertStar", insertStarHandler).Methods("POST") router.HandleFunc("/insertList", insertListHandler).Methods("POST") - //router.HandleFunc("/updatetotalmass/{treeindex}", updateTotalMassHandler).Methods("GET") + router.HandleFunc("/updatetotalmass", updateTotalMassHandler).Methods("POST") + //router.HandleFunc("/updatecenterofmass/{treeindex}", updateCenterOfMassHandler).Methods("GET") //router.HandleFunc("/metrics", metricHandler).Methods("GET") //router.HandleFunc("/export/{treeindex}", exportHandler).Methods("POST") //router.HandleFunc("/nrofgalaxies", nrofgalaxiesHandler).Methods("GET") - // - //router.HandleFunc("/fastinsertjson/{filename}", fastInsertJSONHandler).Methods("GET") - //router.HandleFunc("/fastinsertlist/{filename}/{treeindex}", fastInsertListHandler).Methods("GET") - // - //router.HandleFunc("/readdir/{dirname}", readdirHandler).Methods("GET") db = connectToDB() db.SetMaxOpenConns(75) -- cgit 1.4.1