about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-02-09 19:04:58 +0100
committerEmile <hanemile@protonmail.com>2019-02-09 19:04:58 +0100
commit99dc12b293a4ca096f85c059c04b3c2b6cfb8d00 (patch)
tree32ba0920ec53eeb328dd89cf1f73fa78b357eb06
parent27818b63b78ef33f768e7240b41e9c50bfa63a58 (diff)
added two handlers getting all the stars in go or csv format
-rw-r--r--main.go22
1 files changed, 22 insertions, 0 deletions
diff --git a/main.go b/main.go
index 5fe58ec..88db9a4 100644
--- a/main.go
+++ b/main.go
@@ -112,6 +112,26 @@ func deleteNodesHandler(w http.ResponseWriter, r *http.Request) {
 	deleteNodesEndpoint()
 }
 
+func getListOfStarsGoHandler(w http.ResponseWriter, r *http.Request) {
+	log.Println("[ ] The getListOfStarsGoHandler was accessed")
+
+	listOfStars := listOfStarsGoEndpoint()
+
+	for _, star := range listOfStars {
+		_, _ = fmt.Fprintf(w, "%v\n", star)
+	}
+}
+
+func getListOfStarsCsvHandler(w http.ResponseWriter, r *http.Request) {
+	log.Println("[ ] The getListOfStarsCsvHandler was accessed")
+
+	listOfStars := listOfStarsCsvEndpoint()
+
+	for _, star := range listOfStars {
+		_, _ = fmt.Fprintf(w, "%v\n", star)
+	}
+}
+
 func main() {
 	router := mux.NewRouter()
 
@@ -119,6 +139,8 @@ func main() {
 	router.HandleFunc("/new", newTreeHandler).Methods("POST")
 	router.HandleFunc("/deleteStars", deleteStarsHandler).Methods("POST")
 	router.HandleFunc("/deleteNodes", deleteNodesHandler).Methods("POST")
+	router.HandleFunc("/starlist/go", getListOfStarsGoHandler).Methods("GET")
+	router.HandleFunc("/starlist/csv", getListOfStarsCsvHandler).Methods("GET")
 
 	router.HandleFunc("/insertStar", insertStarHandler).Methods("POST")
 	router.HandleFunc("/insertList", insertListHandler).Methods("POST")