Update the config format.
This commit is contained in:
committed by
François de Metz
parent
daa8dc2bc6
commit
6894033511
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user