Update the config format.

This commit is contained in:
Cyril Duez
2016-06-01 19:35:08 +02:00
committed by François de Metz
parent daa8dc2bc6
commit 6894033511
7 changed files with 37 additions and 68 deletions

View File

@@ -8,22 +8,13 @@ import (
"github.com/gorilla/mux"
"github.com/influxdata/telegraf"
"github.com/influxdata/telegraf/plugins/inputs/webhooks/webhooks_models"
)
func init() {
webhooks_models.Add("github", func(path string) webhooks_models.Webhook { return NewGithubWebhook(path) })
}
type GithubWebhook struct {
Path string
acc telegraf.Accumulator
}
func NewGithubWebhook(path string) *GithubWebhook {
return &GithubWebhook{Path: path}
}
func (gh *GithubWebhook) Register(router *mux.Router, acc telegraf.Accumulator) {
router.HandleFunc(gh.Path, gh.eventHandler).Methods("POST")
log.Printf("Started the webhooks_github on %s\n", gh.Path)

View File

@@ -11,8 +11,7 @@ import (
func GithubWebhookRequest(event string, jsonString string, t *testing.T) {
var acc testutil.Accumulator
gh := NewGithubWebhook("/github")
gh.acc = &acc
gh := &GithubWebhook{Path: "/github", acc: &acc}
req, _ := http.NewRequest("POST", "/github", strings.NewReader(jsonString))
req.Header.Add("X-Github-Event", event)
w := httptest.NewRecorder()