问题是如何在router.go Beego中添加Webhook
// WebhookHandler ...
func (c *AuthController) WebhookHandler(w http.ResponseWriter, r *http.Request) {
publicKeyBytes, err := ioutil.ReadFile("***")
if err != nil {
panic(err)
}
block, _ := pem.Decode(publicKeyBytes)
publicKey, err := x509.ParsePKIXPublicKey(block.Bytes)
if err != nil {
panic(err)
}
key := publicKey.(*rsa.PublicKey)
body, err := ioutil.ReadAll(r.Body)
if err != nil {
return
}
event, ok := VerifySignature(key, body)
if !ok {
return
}
fmt.Println(event)
}
它适用于原始GoLang
http.HandleFunc("/webhook", func(w http.ResponseWriter, r *http.Request) {
***
})
我尝试过
beego.Router("/webhook", &controllers.AuthController{}, "*:WebhookHandler")
但是如何将请求主体传递给控制器