diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-12-25 12:07:59 -0800 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-12-25 12:07:59 -0800 |
commit | 012a0c12e85411777b6c6d9444081e1f6156757d (patch) | |
tree | c075789a97682ffad861916ca66aa635f8672ef4 /system/api/handlers.go | |
parent | 86593ac73bdc10488b869b559678229b87d71fc4 (diff) |
adding more error handling on buffer writes, removing old code
Diffstat (limited to 'system/api/handlers.go')
-rw-r--r-- | system/api/handlers.go | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/system/api/handlers.go b/system/api/handlers.go index 788b2a0..7b59dbd 100644 --- a/system/api/handlers.go +++ b/system/api/handlers.go @@ -180,15 +180,6 @@ func toJSON(data []string) ([]byte, error) { return buf.Bytes(), nil } -func wrapJSON(json []byte) []byte { - var buf = &bytes.Buffer{} - buf.Write([]byte(`{"data":`)) - buf.Write(json) - buf.Write([]byte(`}`)) - - return buf.Bytes() -} - // sendData() should be used any time you want to communicate // data back to a foreign client func sendData(res http.ResponseWriter, data []byte, code int) { @@ -196,7 +187,10 @@ func sendData(res http.ResponseWriter, data []byte, code int) { res.Header().Set("Access-Control-Allow-Origin", "*") res.Header().Set("Content-Type", "application/json") res.WriteHeader(code) - res.Write(data) + _, err := res.Write(data) + if err != nil { + log.Println("Error writing to response in sendData") + } } // SendPreflight is used to respond to a cross-origin "OPTIONS" request |