瀏覽代碼

tech(dataproxy): make the code a little bit more defensive

bergquist 9 年之前
父節點
當前提交
d4a96b9741
共有 1 個文件被更改,包括 4 次插入3 次删除
  1. 4 3
      pkg/api/dataproxy.go

+ 4 - 3
pkg/api/dataproxy.go

@@ -139,9 +139,10 @@ func logProxyRequest(dataSourceType string, c *middleware.Context) {
 		return
 	}
 
-		var body string
-		if c.Req.Request.Body != nil {
-			buffer, _ := ioutil.ReadAll(c.Req.Request.Body)
+	var body string
+	if c.Req.Request.Body != nil {
+		buffer, err := ioutil.ReadAll(c.Req.Request.Body)
+		if err == nil {
 			c.Req.Request.Body = ioutil.NopCloser(bytes.NewBuffer(buffer))
 			body = string(buffer)
 		}