about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-09-23 12:48:28 +0200
committerEmile <hanemile@protonmail.com>2019-09-23 12:48:28 +0200
commit64f62b4ebeb29b52ec8f32f7bf474243903395bf (patch)
tree4df59bb51892d73089b74cbecaba8037c3d00e70
parenteb2e3dc097927399c0c8d1de790702bd8ef9e9fe (diff)
always return json
the api simply always returns the result as json
-rw-r--r--http.go29
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))
 
 }