2 Commits

Author SHA1 Message Date
36fd04cac9 feat: 修改 middleware logger 的格式 2025-08-08 15:46:55 +08:00
956cf69a82 feat: 添加 resp RC 2025-08-06 15:57:49 +08:00
2 changed files with 13 additions and 2 deletions

View File

@ -53,9 +53,8 @@ func New() gin.HandlerFunc {
b := stringBuilderPool.Get().(*strings.Builder)
b.Reset()
b.WriteString("[")
b.WriteString(fmt.Sprintf("%36s", trace))
b.WriteString("] | ")
b.WriteString(" | ")
b.WriteString(fmt.Sprintf("%3d", status))
b.WriteString(" | ")
b.WriteString(fmt.Sprintf("%15s", ip))

View File

@ -30,6 +30,18 @@ func R200(c *gin.Context, data any, msgs ...string) {
c.AbortWithStatusJSON(200, r)
}
func RC(c *gin.Context, status int, args ...any) {
code := 1
if status != 200 {
code = -1
}
_r(c, &res{
Status: status,
Code: code,
}, args...)
}
func RE(c *gin.Context, err error) {
var re *Error