广告平台(站长使用)
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

31 rinda
640 B

  1. package mw
  2. import (
  3. "applet/app/e"
  4. "applet/app/svc"
  5. db "code.fnuoos.com/zhimeng/model.git/src"
  6. "errors"
  7. "fmt"
  8. "github.com/gin-gonic/gin"
  9. )
  10. // DB is 中间件 用来检查master_id是否有对应的数据库engine
  11. func DB(c *gin.Context) {
  12. fmt.Println(c.Request.Header)
  13. masterID := svc.GetMasterId(c)
  14. fmt.Println("master_id", masterID)
  15. if masterID == "" {
  16. e.OutErr(c, e.ERR_MASTER_ID, errors.New("not found master_id"))
  17. return
  18. }
  19. _, ok := db.DBs[masterID]
  20. if !ok {
  21. e.OutErr(c, e.ERR_MASTER_ID, errors.New("not found master_id in DBs"))
  22. return
  23. }
  24. fmt.Println("master_id", masterID)
  25. c.Set("mid", masterID)
  26. c.Next()
  27. }