package mw import ( "fmt" "github.com/gin-gonic/gin" ) // DB is 中间件 用来检查master_id是否有对应的数据库engine func DB(c *gin.Context) { fmt.Println(c.Request.Header) masterID := c.GetHeader("master_id") fmt.Println("master_id", masterID) if masterID == "" { fmt.Println("not found master_id found MasterId start") masterID = c.GetHeader("MasterId") fmt.Println("MasterId", masterID) // if masterID still emtpy } fmt.Println("master_id", masterID) c.Set("mid", masterID) c.Next() }