From c822eecdd23cb626846f956054fa28f7d9f5d062 Mon Sep 17 00:00:00 2001 From: yedongfu Date: Thu, 20 May 2021 17:10:50 +0800 Subject: [PATCH] add error check for handler --- common/utils.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/utils.go b/common/utils.go index 2dd10c7..9af4c46 100644 --- a/common/utils.go +++ b/common/utils.go @@ -111,7 +111,8 @@ func WrapHandler(fn func(*gin.Context) (interface{}, error)) gin.HandlerFunc { logrus.Printf("status: 200, content: %s", string(b)) c.Status(200) c.Writer.Header().Add("Content-Type", "application/json") - c.Writer.Write(b) + _, err = c.Writer.Write(b) + PanicIfError(err) } } }