Skip to content

Commit

Permalink
feat(github-gatewa): added headers to event payload (#536)
Browse files Browse the repository at this point in the history
  • Loading branch information
VaibhavPage authored Mar 10, 2020
1 parent bfc53e6 commit 7f3198f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 14 additions & 1 deletion gateways/server/github/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"encoding/json"
"github.com/argoproj/argo-events/gateways/server"
"github.com/argoproj/argo-events/pkg/apis/events"
"net/http"
"net/url"
"time"
Expand Down Expand Up @@ -105,8 +106,20 @@ func (router *Router) HandleRoute(writer http.ResponseWriter, request *http.Requ
return
}

event := &events.GithubEventData{
Headers: request.Header,
Body: (*json.RawMessage)(&body),
}

eventBody, err := json.Marshal(event)
if err != nil {
logger.Info("failed to marshal event")
common.SendErrorResponse(writer, "invalid event")
return
}

logger.Infoln("dispatching event on route's data channel")
route.DataCh <- body
route.DataCh <- eventBody
logger.Info("request successfully processed")

common.SendSuccessResponse(writer, "success")
Expand Down
4 changes: 3 additions & 1 deletion pkg/apis/events/event-data.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,10 @@ type PubSubEventData struct {

// GithubEventData represents the event data generated by the GitHub gateway.
type GithubEventData struct {
// Headers from the Gitlab http request.
Headers http.Header `json:"headers"`
// Body represents the message body
Body []byte `json:"body"`
Body *json.RawMessage `json:"body"`
}

// GitLabEventData represents the event data generated by the GitLab gateway.
Expand Down

0 comments on commit 7f3198f

Please sign in to comment.