Skip to content

Commit

Permalink
feat:r2上传文件接口不记录进数据库
Browse files Browse the repository at this point in the history
  • Loading branch information
yahahaff committed Jul 24, 2024
1 parent 7cb4757 commit 0d09439
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
10 changes: 8 additions & 2 deletions internal/middlewares/record_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ func RecordOperation() gin.HandlerFunc {
c.Writer = w
start := time.Now()

//GET 请求不记录
if c.Request.Method != "GET" {
notRecordMethods := map[string]bool{
"GET": false,
}

specificURL := "/api/cloudflare/r2/file/upload"

// 判断那些请求方法不被记录
if notRecordMethods[c.Request.Method] && c.Request.URL.Path == specificURL {
defer func() {
requests := string(requestBody)
end := time.Now()
Expand Down
3 changes: 2 additions & 1 deletion internal/routes/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ package routes

import (
"github.com/gin-gonic/gin"
"github.com/yahahaff/rapide/internal/middlewares"
"github.com/yahahaff/rapide/internal/routes/http"
"github.com/yahahaff/rapide/internal/routes/sys"
)

// RegisterAPIRoutes 注册分支路由
func RegisterAPIRoutes(Router *gin.Engine) {
//Router.Use(middlewares.RecordOperation())
Router.Use(middlewares.RecordOperation())
sys.RouterGroup(Router)
http.RouterGroup(Router)

Expand Down

0 comments on commit 0d09439

Please sign in to comment.