about summary refs log tree commit diff
path: root/http.go
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-09-23 12:39:30 +0200
committerEmile <hanemile@protonmail.com>2019-09-23 12:39:30 +0200
commit205c92b576475a3224d88bfef7aa927ca29e08c1 (patch)
tree4b19b8c24b1a2a302dc37d9784dc75bfe786d8ba /http.go
parent1b3545a9f69f61a503f1c996c199c38b11a78e7e (diff)
moved code
moved the code from the dumpallHandler into the dumpall function located in the funcs.go file
Diffstat (limited to 'http.go')
-rw-r--r--http.go27
1 files changed, 3 insertions, 24 deletions
diff --git a/http.go b/http.go
index ece4fde..d1cfb48 100644
--- a/http.go
+++ b/http.go
@@ -14,35 +14,14 @@ import (
 
 // indexHandler displays an index page
 func indexHandler(w http.ResponseWriter, r *http.Request) {
-	fmt.Fprintf(w, "%s", "<h1>Hello World</h1>")
+	fmt.Fprintf(w, "%s", "<h1>TLE2JSON api</h1>")
+	fmt.Fprintf(w, "%s", "Usage: Make a get request to /{station}/{name}")
 }
 
 // dumpallHandler dumps all categories
 func dumpallHandler(w http.ResponseWriter, r *http.Request) {
 	log.Println("[ ] Dumping all TLEs")
-
-	// read the name of the categories from the categories.txt file and write
-	// the result to the categories slice
-	content, err := ioutil.ReadFile("categories.txt")
-	if err != nil {
-		log.Printf("%s\n", "could not read categories.txt file!")
-	}
-	lines := strings.Split(string(content), "\n")
-
-	for _, line := range lines {
-		if line != "" {
-			categories = append(categories, line)
-		}
-	}
-
-	// download all the categories to the data/<category name> directory
-	for _, category := range categories {
-		fmt.Fprintf(w, "downloading %s... ", category)
-		log.Printf("downloading %s... ", category)
-		downloadCategory(category)
-		fmt.Fprintf(w, "done.\n")
-	}
-
+	dumpall()
 	log.Println("[+] Done dumping all TLEs")
 }