This commit is contained in:
laodaming 2023-11-06 15:06:15 +08:00
parent 8c175ad9cc
commit deed8bb14c
2 changed files with 11 additions and 13 deletions

View File

@ -1,7 +1,7 @@
package handler
import (
"fmt"
"encoding/json"
"net/http"
"reflect"
@ -14,13 +14,20 @@ import (
func TicketWebhookHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
fmt.Println(r.Header)
var req types.TicketWebhookReq
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
if err != nil {
return
}
//验证连接
if req.Type == "url_verification" {
challengeRsp := map[string]string{
"challenge": req.Challenge,
}
b, _ := json.Marshal(challengeRsp)
w.Write(b)
return
}
// 创建一个业务逻辑层实例
l := logic.NewTicketWebhookLogic(r.Context(), svcCtx)

View File

@ -1,7 +1,6 @@
package logic
import (
"encoding/json"
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"net/http"
@ -33,15 +32,7 @@ func NewTicketWebhookLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Tic
// }
func (l *TicketWebhookLogic) TicketWebhook(req *types.TicketWebhookReq, userinfo *auth.UserInfo, w http.ResponseWriter) (resp *basic.Response) {
//验证连接
if req.Type == "url_verification" {
challengeRsp := map[string]string{
"challenge": req.Challenge,
}
b, _ := json.Marshal(challengeRsp)
w.Write(b)
return
}
return resp.SetStatusWithMessage(basic.CodeOK, "success")
}