mirror of
https://github.com/axllent/mailpit.git
synced 2026-06-27 22:46:09 +00:00
Chore: Set timeout for HTTP client in webhook Send function
This commit is contained in:
@@ -67,19 +67,18 @@ func Send(msg any) {
|
||||
req.Header.Set("Mailpit-Label", config.Label)
|
||||
}
|
||||
|
||||
client := &http.Client{}
|
||||
client := &http.Client{Timeout: 5 * time.Second}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
logger.Log().Errorf("[webhook] error sending data: %s", err.Error())
|
||||
return
|
||||
}
|
||||
defer func() { _ = resp.Body.Close() }()
|
||||
|
||||
if resp.StatusCode < 200 || resp.StatusCode > 299 {
|
||||
logger.Log().Warnf("[webhook] %s returned a %d status", config.WebhookURL, resp.StatusCode)
|
||||
return
|
||||
}
|
||||
|
||||
_ = resp.Body.Close()
|
||||
})
|
||||
}()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user