diff --git a/plugins/inputs/github_webhooks/github_webhooks.go b/plugins/inputs/github_webhooks/github_webhooks.go index bc3f184be..726eef037 100644 --- a/plugins/inputs/github_webhooks/github_webhooks.go +++ b/plugins/inputs/github_webhooks/github_webhooks.go @@ -73,14 +73,17 @@ func (gh *GithubWebhooks) Stop() { // Handles the / route func (gh *GithubWebhooks) eventHandler(w http.ResponseWriter, r *http.Request) { + defer r.Body.Close() eventType := r.Header["X-Github-Event"][0] data, err := ioutil.ReadAll(r.Body) if err != nil { w.WriteHeader(http.StatusBadRequest) + return } e, err := NewEvent(data, eventType) if err != nil { w.WriteHeader(http.StatusBadRequest) + return } gh.Lock() gh.events = append(gh.events, e)