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.

22 lines
480 B

  1. package middleware
  2. import (
  3. "github.com/flipped-aurora/gin-vue-admin/server/global"
  4. "github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
  5. "github.com/gin-gonic/gin"
  6. )
  7. // 处理跨域请求,支持options访问
  8. func NeedInit() gin.HandlerFunc {
  9. return func(c *gin.Context) {
  10. if global.GVA_DB == nil {
  11. response.OkWithDetailed(gin.H{
  12. "needInit": true,
  13. }, "前往初始化数据库", c)
  14. c.Abort()
  15. } else {
  16. c.Next()
  17. }
  18. // 处理请求
  19. }
  20. }