Only create payload struct once.
(But keep making bytes.Buffer multiple times as these is read from by each http request)
This commit is contained in:
parent
4e3eeec92c
commit
095b55e640
1 changed files with 5 additions and 5 deletions
10
submit.go
10
submit.go
|
@ -521,14 +521,14 @@ func (s *submitServer) submitGenericWebhook(p parsedPayload, listingURL string,
|
||||||
if s.genericWebhookClient == nil {
|
if s.genericWebhookClient == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
genericHookPayload := genericWebhookPayload{
|
||||||
|
parsedPayload: p,
|
||||||
|
ReportURL: reportURL,
|
||||||
|
ListingURL: listingURL,
|
||||||
|
}
|
||||||
for _, url := range s.cfg.GenericWebhookURLs {
|
for _, url := range s.cfg.GenericWebhookURLs {
|
||||||
// Enrich the parsedPayload with a reportURL and listingURL, to convert a single struct
|
// Enrich the parsedPayload with a reportURL and listingURL, to convert a single struct
|
||||||
// to JSON easily
|
// to JSON easily
|
||||||
genericHookPayload := genericWebhookPayload{
|
|
||||||
parsedPayload: p,
|
|
||||||
ReportURL: reportURL,
|
|
||||||
ListingURL: listingURL,
|
|
||||||
}
|
|
||||||
|
|
||||||
payloadBuffer := new(bytes.Buffer)
|
payloadBuffer := new(bytes.Buffer)
|
||||||
json.NewEncoder(payloadBuffer).Encode(genericHookPayload)
|
json.NewEncoder(payloadBuffer).Encode(genericHookPayload)
|
||||||
|
|
Reference in a new issue