劲创营---任务项目
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

mw_check_sign.go 702 B

3 周前
1234567891011121314151617181920212223242526272829303132333435
  1. package mw
  2. import (
  3. "applet/app/comm/e"
  4. "applet/app/comm/utils"
  5. "bytes"
  6. "fmt"
  7. "github.com/gin-gonic/gin"
  8. "io/ioutil"
  9. )
  10. // CheckSign is 中间件 用来检查签名
  11. func CheckSign(c *gin.Context) {
  12. bools := utils.SignCheck(c)
  13. if bools == false {
  14. e.OutErr(c, 400, e.NewErr(400, "签名校验错误,请求失败"))
  15. return
  16. }
  17. c.Next()
  18. }
  19. func CheckBody(c *gin.Context) {
  20. c.Set("api_version", "1")
  21. if utils.GetApiVersion(c) > 0 {
  22. body, _ := ioutil.ReadAll(c.Request.Body)
  23. fmt.Println(string(body))
  24. if string(body) != "" {
  25. str := utils.ResultAesDecrypt(c, string(body))
  26. if str != "" {
  27. c.Request.Body = ioutil.NopCloser(bytes.NewBuffer([]byte(str)))
  28. }
  29. }
  30. }
  31. c.Next()
  32. }