fix: add request timeout
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type CustomWebhook struct {
|
type CustomWebhook struct {
|
||||||
@@ -11,8 +12,12 @@ type CustomWebhook struct {
|
|||||||
Body string
|
Body string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var Client = &http.Client{
|
||||||
|
Timeout: 8 * time.Second,
|
||||||
|
}
|
||||||
|
|
||||||
func (cw *CustomWebhook) Request(url string, msg string) ([]byte, error) {
|
func (cw *CustomWebhook) Request(url string, msg string) ([]byte, error) {
|
||||||
resp, err := http.Post(url, "application/json", bytes.NewBuffer([]byte(msg)))
|
resp, err := Client.Post(url, "application/json", bytes.NewBuffer([]byte(msg)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user