From 0ffe592e42d713c44f4f297493070c1c19f287af Mon Sep 17 00:00:00 2001 From: Deng Ming Date: Sat, 30 Mar 2024 12:54:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=20PureJSON=20=E4=BB=A5?= =?UTF-8?q?=E7=A1=AE=E4=BF=9D=E4=B8=8D=E4=BC=9A=E5=87=BA=E7=8E=B0=E8=BD=AC?= =?UTF-8?q?=E4=B9=89=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wrapper_func.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/wrapper_func.go b/wrapper_func.go index 081060c..89baf47 100644 --- a/wrapper_func.go +++ b/wrapper_func.go @@ -38,10 +38,10 @@ func W(fn func(ctx *Context) (Result, error)) gin.HandlerFunc { } if err != nil { slog.Error("执行业务逻辑失败", slog.Any("err", err)) - ctx.JSON(http.StatusInternalServerError, res) + ctx.PureJSON(http.StatusInternalServerError, res) return } - ctx.JSON(http.StatusOK, res) + ctx.PureJSON(http.StatusOK, res) } } @@ -64,10 +64,10 @@ func B[Req any](fn func(ctx *Context, req Req) (Result, error)) gin.HandlerFunc } if err != nil { slog.Error("执行业务逻辑失败", slog.Any("err", err)) - ctx.JSON(http.StatusInternalServerError, res) + ctx.PureJSON(http.StatusInternalServerError, res) return } - ctx.JSON(http.StatusOK, res) + ctx.PureJSON(http.StatusOK, res) } } @@ -100,10 +100,10 @@ func BS[Req any](fn func(ctx *Context, req Req, sess session.Session) (Result, e } if err != nil { slog.Error("执行业务逻辑失败", slog.Any("err", err)) - ctx.JSON(http.StatusInternalServerError, res) + ctx.PureJSON(http.StatusInternalServerError, res) return } - ctx.JSON(http.StatusOK, res) + ctx.PureJSON(http.StatusOK, res) } } @@ -130,9 +130,9 @@ func S(fn func(ctx *Context, sess session.Session) (Result, error)) gin.HandlerF } if err != nil { slog.Error("执行业务逻辑失败", slog.Any("err", err)) - ctx.JSON(http.StatusInternalServerError, res) + ctx.PureJSON(http.StatusInternalServerError, res) return } - ctx.JSON(http.StatusOK, res) + ctx.PureJSON(http.StatusOK, res) } }