From 205c92b576475a3224d88bfef7aa927ca29e08c1 Mon Sep 17 00:00:00 2001 From: Emile Date: Mon, 23 Sep 2019 12:39:30 +0200 Subject: moved code moved the code from the dumpallHandler into the dumpall function located in the funcs.go file --- http.go | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) (limited to 'http.go') 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", "

Hello World

") + fmt.Fprintf(w, "%s", "

TLE2JSON api

") + 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/ 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") } -- cgit 1.4.1