github wh: return from eventHandler when err != nil

closes #837
This commit is contained in:
Cameron Sparr 2016-03-14 10:29:43 +00:00
parent 8c6c144f28
commit d58ecdfea5
1 changed files with 3 additions and 0 deletions

View File

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