package handler import ( "io" "net/http" "reflect" "fusenapi/utils/basic" "fusenapi/server/pay/internal/logic" "fusenapi/server/pay/internal/svc" "fusenapi/server/pay/internal/types" ) func StripeWebhookHandler(svcCtx *svc.ServiceContext) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { const MaxBodyBytes = int64(65536) r.Body = http.MaxBytesReader(w, r.Body, MaxBodyBytes) defer r.Body.Close() payload, err := io.ReadAll(r.Body) if err != nil { return } var req types.StripeWebhookReq // userinfo, err := basic.RequestParse(w, r, svcCtx, &req) // if err != nil { // return // } req.Payload = payload req.StripeSignature = r.Header.Get("Stripe-Signature") // 创建一个业务逻辑层实例 l := logic.NewStripeWebhookLogic(r.Context(), svcCtx) rl := reflect.ValueOf(l) basic.BeforeLogic(w, r, rl) resp := l.StripeWebhook(&req, nil) if !basic.AfterLogic(w, r, rl, resp) { basic.NormalAfterLogic(w, r, resp) } } }