Skip to content

Commit 7febc56

Browse files
committed
web plugin fix
1 parent 99eb9ac commit 7febc56

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

plugins/web/plugin.go

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"errors"
77
"fmt"
88
"net/http"
9-
"net/url"
109
"time"
1110

1211
log "github.com/Sirupsen/logrus"
@@ -66,19 +65,18 @@ func (p PluginWeb) Unsubscribe(input []byte) error {
6665
}
6766

6867
func (p PluginWeb) ProcessEvent(eventData event.Event) {
69-
req, err := http.NewRequest("POST", "", bytes.NewBuffer(eventData.Payload))
68+
for _, subscribeUrl := range p.storage.Data[eventData.Name] {
69+
go p.sendRequest(subscribeUrl, eventData.Payload)
70+
}
71+
}
72+
73+
func (p PluginWeb) sendRequest(url string, payload []byte) {
74+
req, err := http.NewRequest("POST", url, bytes.NewBuffer(payload))
7075
if err != nil {
7176
log.Error(err)
7277
return
7378
}
7479
req.Header.Set("Content-Type", "application/json")
75-
for _, subscribeUrl := range p.storage.Data[eventData.Name] {
76-
req.URL, err = url.Parse(subscribeUrl)
77-
if err != nil {
78-
log.Error(err)
79-
continue
80-
}
81-
// TODO: add ability to log statistics
82-
go p.client.Do(req)
83-
}
80+
// TODO: log statistics
81+
p.client.Do(req)
8482
}

0 commit comments

Comments
 (0)