mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-20 17:57:54 +00:00
修改文件目录
This commit is contained in:
@@ -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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user