package mw import ( "applet/app/cfg" "applet/app/e" "applet/app/lib/aes" "applet/app/lib/aes/md" "applet/app/utils" "errors" "fmt" "github.com/gin-gonic/gin" ) // CheckSign is 中间件 用来检查签名 func CheckSign(c *gin.Context) { if !(utils.GenerateMD5Hash(c.Request.Host) == md.ConvenientKeyForTest || (c.GetHeader("is_check") == "false" && !cfg.Prd)) { err := aes.CheckSign(c) if err != nil { if cfg.Prd { fmt.Println("签名问题:" + err.Error()) e.OutErr(c, 400, errors.New("请求失败~~")) } else { e.OutErr(c, 400, "验签失败: "+err.Error()) } return } c.Next() c.Set("is_sign", true) } }