refactor: verifyWebhookDataMiddleware just need to store the wehbook data in context

This commit is contained in:
Derrick Hammer 2024-02-11 04:25:52 -05:00
parent 36a661bd71
commit 90fbbf94e1
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
2 changed files with 2 additions and 1 deletions

View File

@ -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{}

View File

@ -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")
} }