|
12345678910111213141516171819202122232425262728293031323334 |
- package mw
-
- import (
- "applet/app/e"
- "applet/app/utils"
- "bytes"
- "fmt"
- "github.com/gin-gonic/gin"
- "io/ioutil"
- )
-
- // CheckSign is 中间件 用来检查签名
- func CheckSign(c *gin.Context) {
-
- bools := utils.SignCheck(c)
- if bools == false {
- e.OutErr(c, 400, e.NewErr(400, "签名校验错误,请求失败"))
- return
- }
- c.Next()
- }
- func CheckBody(c *gin.Context) {
- if utils.GetApiVersion(c) > 0 {
- body, _ := ioutil.ReadAll(c.Request.Body)
- fmt.Println(string(body))
- if string(body) != "" {
- str := utils.ResultAesDecrypt(c, string(body))
- if str != "" {
- c.Request.Body = ioutil.NopCloser(bytes.NewBuffer([]byte(str)))
- }
- }
- }
- c.Next()
- }
|