diff options
-rw-r--r-- | http.go | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/http.go b/http.go index 91c5c77..c1f1e6f 100644 --- a/http.go +++ b/http.go @@ -63,25 +63,18 @@ func getHandler(w http.ResponseWriter, r *http.Request) { RawTLE := strings.Join(lines[j:j+3], "\n") - // handle the response according to the query parameter "format" - // if ?format=json is given, return - if r.URL.Query().Get("format") == "json" { - w.Header().Set("Content-Type", "application/json") - - JSONTLE, err := tle.NewTLE(RawTLE) - if err != nil { - fmt.Println(err) - } + w.Header().Set("Content-Type", "application/json") - // convert the TLE to json - b, err := json.MarshalIndent(JSONTLE, "", " ") - if err != nil { - fmt.Println("error: ", err) - } - fmt.Fprintf(w, string(b)) - //fmt.Fprintf(w, "{\"response\": \"Getting the TLE for %s/%s as json\"}", vars["station"], vars["name"]) - } else { - fmt.Fprintf(w, "Getting the TLE for %s/%s raw", vars["station"], vars["name"]) + JSONTLE, err := tle.NewTLE(RawTLE) + if err != nil { + fmt.Println(err) + } + + // convert the TLE to json + b, err := json.MarshalIndent(JSONTLE, "", " ") + if err != nil { + fmt.Println("error: ", err) } + fmt.Fprintf(w, string(b)) } |