diff options
Diffstat (limited to 'http.go')
-rw-r--r-- | http.go | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/http.go b/http.go index c1f1e6f..4c77fcb 100644 --- a/http.go +++ b/http.go @@ -6,7 +6,6 @@ import ( "io/ioutil" "log" "net/http" - "os" "strings" tle "git.darknebu.la/Satellite/tle" @@ -30,19 +29,12 @@ func dumpallHandler(w http.ResponseWriter, r *http.Request) { func getHandler(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) - // read the TLEs from the categories file - // TODO: Handle caching - // - dump all if not present - // - if old, fetch from celestrack - // define where the file containing the spoecified categories lies categoryPath := fmt.Sprintf("data/%s.txt", vars["station"]) - // find out if the file exists or not - if _, err := os.Stat(categoryPath); os.IsNotExist(err) { - // if it does not exist, download the category - downloadCategory(vars["station"]) - } + // this will only download the category if the file does not exist or if it + // is to old + downloadCategory(vars["station"]) // open the file containing the data for the individual station content, err := ioutil.ReadFile(categoryPath) |