admin_middleware.go 387 B

1234567891011121314151617181920
  1. package middlewares
  2. import (
  3. "bigdata_archives/app/e"
  4. "bigdata_archives/utils"
  5. "github.com/gin-gonic/gin"
  6. )
  7. func AdminMiddleware() gin.HandlerFunc {
  8. return func(c *gin.Context) {
  9. header := c.GetHeader("Authorization")
  10. _, recode := utils.ParseToken(header)
  11. if recode != e.SUCCESS {
  12. e.ResponseWithMsg(c, recode, recode.GetMsg())
  13. c.Abort()
  14. } else {
  15. c.Next()
  16. }
  17. }
  18. }