Error before sending json object if something bad happend with reading a request body

This commit is contained in:
Denis Makogon
2017-10-07 02:33:43 +03:00
parent 5e9bf0d708
commit 6141344e5f

View File

@@ -37,6 +37,9 @@ func (h *JSONProtocol) DumpJSON(req *http.Request) error {
stdin := json.NewEncoder(h.in)
bb := new(bytes.Buffer)
_, err := bb.ReadFrom(req.Body)
if err != nil {
return err
}
err = writeString(err, h.in, "{")
err = writeString(err, h.in, `"body":`)
err = stdin.Encode(bb.String())