From dd77f4cf28ee3f13074303a9fe7aa9d0b1bb5f61 Mon Sep 17 00:00:00 2001 From: Emile Date: Sat, 9 Feb 2019 19:05:21 +0100 Subject: updated / added a few endpoints --- http.go | 31 ++++++++++++++++++++----------- 1 file 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 } -- cgit 1.4.1