refactor: verifyWebhookDataMiddleware just need to store the wehbook data in context
This commit is contained in:
parent
36a661bd71
commit
90fbbf94e1
|
@ -63,7 +63,7 @@ func giteaOauthVerifyMiddleware(cfg *config.Config) mux.MiddlewareFunc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func verifyWebhookDataMiddleware(cfg *config.Config, logger *zap.Logger) mux.MiddlewareFunc {
|
func storeWebhookDataMiddleware(logger *zap.Logger) mux.MiddlewareFunc {
|
||||||
return func(next http.Handler) http.Handler {
|
return func(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
var webhook map[string]interface{}
|
var webhook map[string]interface{}
|
||||||
|
|
|
@ -44,6 +44,7 @@ func setupWebhookRoutes(params RouteParams) {
|
||||||
webhookRouter := r.PathPrefix("/api").Subrouter()
|
webhookRouter := r.PathPrefix("/api").Subrouter()
|
||||||
|
|
||||||
webhookRouter.Use(gitea.VerifyWebhookSignatureMiddleware(cfg.GiteaWebHookSecret))
|
webhookRouter.Use(gitea.VerifyWebhookSignatureMiddleware(cfg.GiteaWebHookSecret))
|
||||||
|
webhookRouter.Use(storeWebhookDataMiddleware(logger))
|
||||||
|
|
||||||
webhookRouter.HandleFunc("/webhooks/pull_request", webhookApi.handlePullRequest).Methods("POST")
|
webhookRouter.HandleFunc("/webhooks/pull_request", webhookApi.handlePullRequest).Methods("POST")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue