From 42dfd20eb9000e8cf68f7f09368fbe09c23e950d Mon Sep 17 00:00:00 2001 From: Daniel Ledda Date: Wed, 4 Nov 2020 19:01:11 +0100 Subject: [PATCH] Working --- Snapshot.go | 4 ++-- climate-server.go | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Snapshot.go b/Snapshot.go index d140a76..e7f85b3 100644 --- a/Snapshot.go +++ b/Snapshot.go @@ -7,7 +7,7 @@ import ( "io/ioutil" ) -type SnapshotListResponse struct { +type SnapshotPayload struct { Snapshots []*SnapshotRecord `json:"snapshots"` } @@ -41,7 +41,7 @@ func createSnapshotSubFromJsonBodyStream(jsonBodyStream io.ReadCloser) (*Snapsho } func createJsonFromSnapshotRecords(records []*SnapshotRecord) ([]byte, error) { - jsonResult, err := json.Marshal(SnapshotListResponse{records}) + jsonResult, err := json.Marshal(SnapshotPayload{records}) if err != nil { return nil, err } diff --git a/climate-server.go b/climate-server.go index cc3504a..6dd5a4c 100644 --- a/climate-server.go +++ b/climate-server.go @@ -52,6 +52,7 @@ func sendData(w http.ResponseWriter, r *http.Request) error { if err != nil { return fmt.Errorf("couldn't create a json from the records: %w", err) } + w.Header().Set("Content-Type", "application/json") _, err = fmt.Fprintf(w, string(json)) return err }