Files
jx-callback/controllers/weixin_callback.go
苏尹岚 6bf4ce45a5 aa
2021-03-31 16:20:11 +08:00

29 lines
671 B
Go

package controllers
import (
"net/http"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
"github.com/astaxie/beego/server/web"
)
type WeixinController struct {
web.Controller
}
func (c *WeixinController) Msg() {
if c.Ctx.Input.Method() == http.MethodGet {
signature := c.GetString("signature")
timestamp := c.GetString("timestamp")
nonce := c.GetString("nonce")
echostr := c.GetString("echostr")
isValid := api.WeixinAPI.ValidateWXCallbackURL(signature, timestamp, nonce)
globals.SugarLogger.Debugf("weixin URL check is:%t", isValid)
c.Ctx.WriteString(echostr)
} else {
c.Data["json"] = "ok"
c.ServeJSON()
}
}