Respond 200 when receiving a ping event. (#2492)
This commit is contained in:
parent
2fe161356b
commit
e76dcf09ec
|
@ -34,9 +34,10 @@ func (gh *GithubWebhook) eventHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if e != nil {
|
||||||
p := e.NewMetric()
|
p := e.NewMetric()
|
||||||
gh.acc.AddFields("github_webhooks", p.Fields(), p.Tags(), p.Time())
|
gh.acc.AddFields("github_webhooks", p.Fields(), p.Tags(), p.Time())
|
||||||
|
}
|
||||||
|
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
|
@ -84,6 +85,8 @@ func NewEvent(data []byte, name string) (Event, error) {
|
||||||
return generateEvent(data, &MembershipEvent{})
|
return generateEvent(data, &MembershipEvent{})
|
||||||
case "page_build":
|
case "page_build":
|
||||||
return generateEvent(data, &PageBuildEvent{})
|
return generateEvent(data, &PageBuildEvent{})
|
||||||
|
case "ping":
|
||||||
|
return nil, nil
|
||||||
case "public":
|
case "public":
|
||||||
return generateEvent(data, &PublicEvent{})
|
return generateEvent(data, &PublicEvent{})
|
||||||
case "pull_request":
|
case "pull_request":
|
||||||
|
|
|
@ -25,6 +25,10 @@ func TestCommitCommentEvent(t *testing.T) {
|
||||||
GithubWebhookRequest("commit_comment", CommitCommentEventJSON(), t)
|
GithubWebhookRequest("commit_comment", CommitCommentEventJSON(), t)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestPingEvent(t *testing.T) {
|
||||||
|
GithubWebhookRequest("ping", "", t)
|
||||||
|
}
|
||||||
|
|
||||||
func TestDeleteEvent(t *testing.T) {
|
func TestDeleteEvent(t *testing.T) {
|
||||||
GithubWebhookRequest("delete", DeleteEventJSON(), t)
|
GithubWebhookRequest("delete", DeleteEventJSON(), t)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue