使用action代替api单个操作

改写job
This commit is contained in:
linwenxiang committed 2020-08-29 22:22:52 +08:00
1 parent 78417c2d33
commit 562e61cf4f
15 files changed
+332 -6

No files matched your search

+17
View File
@@ -0,0 +1,17 @@
package middleware
import (
"github.com/gin-gonic/gin"
"gorm.io/gorm"
)
func WithContextDb(dbMap map[string]*gorm.DB) gin.HandlerFunc {
return func(c *gin.Context) {
if db, ok := dbMap["*"]; ok {
c.Set("db", db)
} else {
c.Set("db", dbMap[c.Request.Host])
}
c.Next()
}
}