修复富文本bug,调整日志输出,修复已知bug (#1563)

* operation.go: fix 调用respPool.Put归还对象前清空对象会造成下次调用无法正常copy
redis.go: fix NewDefaultRedisStore方法实例化的对象直接使用会造成空指针异常

* 设置为发布模式时gin不再输出路由信息log

* 调整基础配置文件

* 修复富文本不回显的bug

---------

Co-authored-by: liuyahui <liuyahui@wjacloud.com>
Co-authored-by: Alan <alan.cd@qq.com>
Co-authored-by: wuqianang <wuqianang@163.com>
Co-authored-by: task <ms.yangdan@gmail.com>
This commit is contained in:
奇淼(piexlmax
2023-10-10 16:41:55 +08:00
committed by GitHub
parent 10dc003f20
commit 18694fd24a
6 changed files with 18 additions and 8 deletions

View File

@@ -23,10 +23,11 @@ import (
var operationRecordService = service.ServiceGroupApp.SystemServiceGroup.OperationRecordService
var respPool sync.Pool
var bufferSize = 1024
func init() {
respPool.New = func() interface{} {
return make([]byte, 1024)
return make([]byte, bufferSize)
}
}
@@ -56,7 +57,7 @@ func OperationRecord() gin.HandlerFunc {
body, _ = json.Marshal(&m)
}
claims, _ := utils.GetClaims(c)
if claims.BaseClaims.ID != 0 {
if claims != nil && claims.BaseClaims.ID != 0 {
userId = int(claims.BaseClaims.ID)
} else {
id, err := strconv.Atoi(c.Request.Header.Get("x-user-id"))
@@ -76,12 +77,12 @@ func OperationRecord() gin.HandlerFunc {
// 上传文件时候 中间件日志进行裁断操作
if strings.Contains(c.GetHeader("Content-Type"), "multipart/form-data") {
if len(record.Body) > 1024 {
if len(record.Body) > bufferSize {
// 截断
newBody := respPool.Get().([]byte)
copy(newBody, record.Body)
record.Body = string(newBody)
defer respPool.Put(newBody[:0])
defer respPool.Put(newBody)
}
}
@@ -109,12 +110,12 @@ func OperationRecord() gin.HandlerFunc {
strings.Contains(c.Writer.Header().Get("Content-Type"), "application/download") ||
strings.Contains(c.Writer.Header().Get("Content-Disposition"), "attachment") ||
strings.Contains(c.Writer.Header().Get("Content-Transfer-Encoding"), "binary") {
if len(record.Resp) > 1024 {
if len(record.Resp) > bufferSize {
// 截断
newBody := respPool.Get().([]byte)
copy(newBody, record.Resp)
record.Resp = string(newBody)
defer respPool.Put(newBody[:0])
defer respPool.Put(newBody)
}
}