附近小店
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.

mw_check_sign.go 773 B

3 月之前
12345678910111213141516171819202122232425262728293031323334353637
  1. package mw
  2. import (
  3. "applet/app/e"
  4. "applet/app/utils"
  5. "bytes"
  6. "errors"
  7. "fmt"
  8. "github.com/gin-gonic/gin"
  9. "io/ioutil"
  10. )
  11. // CheckSign is 中间件 用来检查签名
  12. func CheckSign(c *gin.Context) {
  13. if utils.SignCheck(c) == false {
  14. e.OutErr(c, 400, errors.New("请求失败~~"))
  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("check_", c.GetString("mid"), string(body))
  24. if string(body) != "" {
  25. str := utils.ResultAesDecrypt(c, string(body))
  26. fmt.Println("check_de", c.GetString("mid"), str)
  27. if str != "" {
  28. c.Set("body_str", str)
  29. c.Request.Body = ioutil.NopCloser(bytes.NewBuffer([]byte(str)))
  30. }
  31. }
  32. }
  33. c.Next()
  34. }