about summary refs log tree commit diff
diff options
context:
space:
mode:
authorhanemile <hanemile@protonmail.com>2019-01-25 13:51:28 +0100
committerhanemile <hanemile@protonmail.com>2019-01-25 13:51:28 +0100
commit98ad44e1f28d2c271ffb6bed95aaeb03a69dccc9 (patch)
treeec2f06c9ebf5b22513b2bdfba8eb92847ced811f
parente7951d4b5cf882169b2e849c2d28187cf643c1c1 (diff)
push
-rw-r--r--main.go13
1 files changed, 9 insertions, 4 deletions
diff --git a/main.go b/main.go
index 2e527f6..5e58f1e 100644
--- a/main.go
+++ b/main.go
@@ -17,8 +17,7 @@ var (
 	errorCount []int
 )
 
-// indexHandler
-func indexHandler(w http.ResponseWriter, r *http.Request) {
+func index() string {
 	infostring := `Galaxy Simulator Database
 
 API:
@@ -40,9 +39,15 @@ API:
 
 	- /readdir ("GET")
 `
-	_, _ = fmt.Fprintf(w, infostring)
+	return infostring
+}
+
+// indexHandler
+func indexHandler(w http.ResponseWriter, r *http.Request) {
+	_, _ = fmt.Fprintf(w, index())
 }
 
+// readdirHandler reads the content of a given directory and prints it
 func readdirHandler(w http.ResponseWriter, r *http.Request) {
 	vars := mux.Vars(r)
 	dirname := vars["dirname"]
@@ -84,7 +89,7 @@ func main() {
 	router.HandleFunc("/fastinsertjson/{filename}", fastInsertJSONHandler).Methods("GET")
 	router.HandleFunc("/fastinsertlist/{filename}/{treeindex}", fastInsertListHandler).Methods("GET")
 
-	// router.HandleFunc("/readdir/{dirname}", readdirHandler).Methods("GET")
+	router.HandleFunc("/readdir/{dirname}", readdirHandler).Methods("GET")
 
 	fmt.Println("Database Container up")
 	log.Fatal(http.ListenAndServe(":80", router))