Compare commits
No commits in common. "b6d8cece7d1ed85c1d486ce165f36c93b3d1d478" and "aa92e682969bd6846cca4a22bb19e2e2b2a57f1c" have entirely different histories.
b6d8cece7d
...
aa92e68296
|
|
@ -1,7 +1,6 @@
|
||||||
package handler
|
package handler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"net/http"
|
"net/http"
|
||||||
"videoplayer/dao"
|
"videoplayer/dao"
|
||||||
|
|
@ -32,11 +31,10 @@ func UploadFile(c *gin.Context) {
|
||||||
id1 := int(id.(float64))
|
id1 := int(id.(float64))
|
||||||
//从请求头获取upload_type
|
//从请求头获取upload_type
|
||||||
uploadType := c.Request.Header.Get("upload_type")
|
uploadType := c.Request.Header.Get("upload_type")
|
||||||
fmt.Println("header:", c.Request.Header)
|
if uploadType == "" {
|
||||||
//if uploadType == "" {
|
c.JSON(http.StatusOK, gin.H{"error": "upload_type is empty", "code": proto.ParameterError, "message": "failed"})
|
||||||
// c.JSON(http.StatusOK, gin.H{"error": "upload_type is empty", "code": proto.ParameterError, "message": "failed"})
|
return
|
||||||
// return
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
user := dao.FindUserByUserID(id1)
|
user := dao.FindUserByUserID(id1)
|
||||||
if user.Upload == false {
|
if user.Upload == false {
|
||||||
|
|
|
||||||
6
main.go
6
main.go
|
|
@ -50,11 +50,10 @@ func writeLogger(c *gin.Context) {
|
||||||
method := c.Request.Method
|
method := c.Request.Method
|
||||||
path := c.Request.URL.Path
|
path := c.Request.URL.Path
|
||||||
params := ""
|
params := ""
|
||||||
|
|
||||||
if method == "GET" {
|
if method == "GET" {
|
||||||
params = c.Request.URL.RawQuery
|
params = c.Request.URL.RawQuery
|
||||||
}
|
}
|
||||||
if method == "POST" && !strings.Contains(c.Request.URL.Path, "/upload") {
|
if method == "POST" {
|
||||||
params = c.Request.PostForm.Encode()
|
params = c.Request.PostForm.Encode()
|
||||||
if params == "" {
|
if params == "" {
|
||||||
// 请求体
|
// 请求体
|
||||||
|
|
@ -63,9 +62,6 @@ func writeLogger(c *gin.Context) {
|
||||||
params = string(bodyBytes)
|
params = string(bodyBytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if strings.Contains(c.Request.URL.Path, "/upload") {
|
|
||||||
params = "upload file"
|
|
||||||
}
|
|
||||||
go dao.InsertLogToDB(path, ip, method, params)
|
go dao.InsertLogToDB(path, ip, method, params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue