parent
34c4f4bf53
commit
77513a871f
|
@ -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)
|
||||||
|
|
|
@ -195,7 +195,7 @@ func (i *InfluxDB) Write(metrics []telegraf.Metric) error {
|
||||||
// If all of the writes failed, create a new connection array so that
|
// If all of the writes failed, create a new connection array so that
|
||||||
// i.Connect() will be called on the next gather.
|
// i.Connect() will be called on the next gather.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
i.conns = make([]client.Client)
|
i.conns = make([]client.Client, 0)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue