File tree Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Expand file tree Collapse file tree 1 file changed +9
-11
lines changed Original file line number Diff line number Diff line change 6
6
"errors"
7
7
"fmt"
8
8
"net/http"
9
- "net/url"
10
9
"time"
11
10
12
11
log "github.com/Sirupsen/logrus"
@@ -66,19 +65,18 @@ func (p PluginWeb) Unsubscribe(input []byte) error {
66
65
}
67
66
68
67
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 ))
70
75
if err != nil {
71
76
log .Error (err )
72
77
return
73
78
}
74
79
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 )
84
82
}
You can’t perform that action at this time.
0 commit comments