广告平台(媒体使用)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

31 rivejä
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. }