Skip to content

Commit 8aa70fc

Browse files
committed
add timeout for http client
1 parent 86fa446 commit 8aa70fc

File tree

1 file changed

+4
-1
lines changed
  • internal/platform/repositories/alert

1 file changed

+4
-1
lines changed

internal/platform/repositories/alert/helper.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"net/http"
88
"strconv"
99
"strings"
10+
"time"
1011

1112
"github.com/hatamiarash7/uptime-webhook/internal/models"
1213
log "github.com/sirupsen/logrus"
@@ -21,7 +22,9 @@ func sendPOSTRequest(url string, payload []byte, version string) (string, error)
2122
}
2223

2324
// Send the request
24-
client := http.Client{}
25+
client := http.Client{
26+
Timeout: 5 * time.Second,
27+
}
2528
req.Header.Add("Content-Type", "application/json")
2629
req.Header.Add("User-Agent", "ArvanCloud-Uptime/"+version)
2730
resp, err := client.Do(req)

0 commit comments

Comments
 (0)