about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-02-10 17:08:55 +0100
committerEmile <hanemile@protonmail.com>2019-02-10 17:08:55 +0100
commit63b337332575256131184d19e2208bba326c426c (patch)
treec33829e6497ba8500348ca70baea4afe9cf6a8d4
parentadb2c417158ca47a9b99bad5399e361b37e9d323 (diff)
implemented the updateTotalMass function
-rw-r--r--main.go23
1 files 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)