prow/hook/server.go
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	eventType, eventGUID, payload, ok, resp := github.ValidateWebhook(w, r, s.TokenGenerator())
	if counter, err := s.Metrics.WebhookCounter.GetMetricWithLabelValues(strconv.Itoa(resp)); err != nil {
		logrus.WithFields(logrus.Fields{
			"status-code": resp,
		}).WithError(err).Error("Failed to get metric for reporting webhook status code")
	} else {
		counter.Inc()
	}

	if !ok {
		return
	}
	fmt.Fprint(w, "Event received. Have a nice day.")

	if err := s.demuxEvent(eventType, eventGUID, payload, r.Header); err != nil {
		logrus.WithError(err).Error("Error parsing event.")
	}
}
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	eventType, eventGUID, payload, ok, resp := github.ValidateWebhook(w, r, s.TokenGenerator())
	if counter, err := s.Metrics.WebhookCounter.GetMetricWithLabelValues(strconv.Itoa(resp)); err != nil {
		logrus.WithFields(logrus.Fields{
			"status-code": resp,
		}).WithError(err).Error("Failed to get metric for reporting webhook status code")
	} else {
		counter.Inc()
	}

	if !ok {
		return
	}
	fmt.Fprint(w, "Event received. Have a nice day.")

	if err := s.demuxEvent(eventType, eventGUID, payload, r.Header); err != nil {
		logrus.WithError(err).Error("Error parsing event.")
	}
}
func ( s * Server ) ServeHTTP ( w http . ResponseWriter , r * http . Request ) { eventType , eventGUID , payload , ok , resp := github . ValidateWebhook ( w , r , s . TokenGenerator ( ) ) if counter , err := s . Metrics . WebhookCounter . GetMetricWithLabelValues ( strconv . Itoa ( resp ) ) ; err != nil { logrus . WithFields ( logrus . Fields { " " : resp , } ) . WithError ( err ) . Error ( " " ) } else { counter . Inc ( ) } if ! ok { return } fmt . Fprint ( w , " " ) if err := s . demuxEvent ( eventType , eventGUID , payload , r . Header ) ; err != nil { logrus . WithError ( err ) . Error ( " " ) } }
// ServeHTTP validates an incoming webhook and puts it into the event channel.
ServeHTTP validates an incoming webhook and puts it into the event channel .