Skip to content

Commit

Permalink
Merge pull request statping#80 from ryanoolala/fix-webhook-apikey
Browse files Browse the repository at this point in the history
Fix: issue with api_key in webhook
  • Loading branch information
hunterlong authored Oct 11, 2018
2 parents b545143 + 9dab20e commit 9498e86
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions notifiers/webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ func (w *webhooker) run(body string) (*http.Response, error) {
req.Header.Add(split[0], split[1])
}
}
if w.ApiSecret != "" {
req.Header.Add("Content-Type", w.ApiSecret)
if w.ApiKey != "" {
req.Header.Add("Content-Type", w.ApiKey)
}
resp, err := client.Do(req)
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions notifiers/webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
var (
WEBHOOK_URL = "https://jsonplaceholder.typicode.com/posts"
webhookMessage = `{ "title": "%service.Id", "body": "%service.Name", "online": %service.Online, "userId": 19999 }`
apiKey = "application/json"
fullMsg string
)

Expand All @@ -41,10 +42,12 @@ func TestWebhookNotifier(t *testing.T) {
t.Run("Load webhooker", func(t *testing.T) {
webhook.Host = WEBHOOK_URL
webhook.Delay = time.Duration(100 * time.Millisecond)
webhook.ApiKey = apiKey
err := notifier.AddNotifier(webhook)
assert.Nil(t, err)
assert.Equal(t, "Hunter Long", webhook.Author)
assert.Equal(t, WEBHOOK_URL, webhook.Host)
assert.Equal(t, apiKey, webhook.ApiKey)
})

t.Run("Load webhooker Notifier", func(t *testing.T) {
Expand Down

0 comments on commit 9498e86

Please sign in to comment.