From 90fbbf94e1b1d47521e782219789ea50f9ece5d8 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 11 Feb 2024 04:25:52 -0500 Subject: [PATCH] refactor: verifyWebhookDataMiddleware just need to store the wehbook data in context --- api/middleware.go | 2 +- api/routes_webhooks.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/api/middleware.go b/api/middleware.go index 8093970..e7e00cb 100644 --- a/api/middleware.go +++ b/api/middleware.go @@ -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 http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { var webhook map[string]interface{} diff --git a/api/routes_webhooks.go b/api/routes_webhooks.go index dd71ec2..571a310 100644 --- a/api/routes_webhooks.go +++ b/api/routes_webhooks.go @@ -44,6 +44,7 @@ func setupWebhookRoutes(params RouteParams) { webhookRouter := r.PathPrefix("/api").Subrouter() webhookRouter.Use(gitea.VerifyWebhookSignatureMiddleware(cfg.GiteaWebHookSecret)) + webhookRouter.Use(storeWebhookDataMiddleware(logger)) webhookRouter.HandleFunc("/webhooks/pull_request", webhookApi.handlePullRequest).Methods("POST") }