about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-02-09 19:05:21 +0100
committerEmile <hanemile@protonmail.com>2019-02-09 19:05:21 +0100
commitdd77f4cf28ee3f13074303a9fe7aa9d0b1bb5f61 (patch)
treeb68dc960ca0eb9c1976cf32cb0d6930eebc4481c
parent99dc12b293a4ca096f85c059c04b3c2b6cfb8d00 (diff)
updated / added a few endpoints
-rw-r--r--http.go31
1 files changed, 20 insertions, 11 deletions
diff --git a/http.go b/http.go
index 822a552..ad74306 100644
--- a/http.go
+++ b/http.go
@@ -16,9 +16,7 @@
 
 package main
 
-import (
-	"git.darknebu.la/GalaxySimulator/structs"
-)
+import "git.darknebu.la/GalaxySimulator/structs"
 
 // IndexEndpoint gives a basic overview over the api
 func indexEndpoint() string {
@@ -49,24 +47,35 @@ API:
 
 // newTree creates a new tree
 func newTreeEndpoint(width float64) {
-	db := connectToDB()
-	newTree(db, width)
+	newTree(width)
 }
 
 // insertStarEndpoint inserts the star into the tree with the given index
 func insertStarEndpoint(star structs.Star2D, index int64) {
-	db := connectToDB()
-	insertStar(db, star, index)
+	insertStar(star, index)
+}
+
+// insertListEndpoint inserts the star into the tree with the given index
+func insertListEndpoint(filename string) {
+	insertList(filename)
 }
 
 // deleteStarsEndpoint deletes all the rows from the stars table
 func deleteStarsEndpoint() {
-	db := connectToDB()
-	deleteAllStars(db)
+	deleteAllStars()
 }
 
 // deleteNodesEndpoint deletes all the rows from the nodes table
 func deleteNodesEndpoint() {
-	db := connectToDB()
-	deleteAllNodes(db)
+	deleteAllNodes()
+}
+
+func listOfStarsGoEndpoint() []structs.Star2D {
+	listOfStars := getListOfStarsGo()
+	return listOfStars
+}
+
+func listOfStarsCsvEndpoint() []string {
+	listOfStars := getListOfStarsCsv()
+	return listOfStars
 }