Compare commits
No commits in common. "086fe399e44d2aa8b8a78e3aa382c8c7d8a44589" and "dc8a872e5e7b99e23644bc939066e03c1a99ff02" have entirely different histories.
086fe399e4
...
dc8a872e5e
@ -3,7 +3,6 @@ package middleware
|
||||
import (
|
||||
"bytes"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
@ -25,17 +24,14 @@ func NewLogger() gin.HandlerFunc {
|
||||
latencyTime := endTime.Sub(startTime) // 请求方式
|
||||
path := c.Request.URL.Path
|
||||
query := c.Request.URL.RawQuery
|
||||
data, _ := io.ReadAll(c.Request.Body)
|
||||
val := c.GetHeader("Accept-Language")
|
||||
if val == "" {
|
||||
c.Request.Header.Set("Accept-Language", "zh-CN")
|
||||
}
|
||||
if _, err := c.FormFile("file"); err != nil {
|
||||
data, _ := io.ReadAll(c.Request.Body)
|
||||
log.Printf("[%s] %s %d %s %s %s %s %s %s", path, c.Request.Method, c.Writer.Status(), query,
|
||||
string(data), c.ClientIP(), c.Request.UserAgent(), c.Errors.ByType(gin.ErrorTypePrivate).String(), latencyTime.String())
|
||||
|
||||
c.Request.Body = ioutil.NopCloser(bytes.NewBuffer(data))
|
||||
}
|
||||
log.Printf("[%s] %s %d %s %s %s %s %s %s", path, c.Request.Method, c.Writer.Status(), query,
|
||||
string(data), c.ClientIP(), c.Request.UserAgent(), c.Errors.ByType(gin.ErrorTypePrivate).String(), latencyTime.String())
|
||||
c.Request.Body = io.NopCloser(bytes.NewBuffer(data))
|
||||
c.Next()
|
||||
}
|
||||
}
|
||||
|
@ -337,8 +337,7 @@ func UploadWithBuffer(fileBuffer *bytes.Buffer, cloudStoreSubPath string) (url s
|
||||
return
|
||||
}
|
||||
cloudStoreSubPath = getEnvDir(cloudStoreSubPath)
|
||||
_, err = Client.PutObjectFromBytes(config.ConfigData.Oss.BucketName, cloudStoreSubPath, fileBuffer.Bytes())
|
||||
url = config.ConfigData.Oss.CdnHost + "/" + cloudStoreSubPath
|
||||
url, err = Client.PutObjectFromBytes(config.ConfigData.Oss.BucketName, cloudStoreSubPath, fileBuffer.Bytes())
|
||||
return
|
||||
}
|
||||
func getEnvDir(cloudStoreSubPath string) (ep string) {
|
||||
|
Loading…
Reference in New Issue
Block a user