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