Skip to content

Commit

Permalink
使用 PureJSON 以确保不会出现转义问题 (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
flycash authored Mar 30, 2024
1 parent 0c3345e commit 80840e6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions wrapper_func.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand All @@ -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)
}
}

Expand Down Expand Up @@ -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)
}
}

Expand All @@ -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)
}
}

0 comments on commit 80840e6

Please sign in to comment.