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