From 8aa70fc000b17f35d93083609c55ee13403f837e Mon Sep 17 00:00:00 2001 From: Arash Hatami Date: Wed, 26 Jul 2023 22:43:16 +0330 Subject: [PATCH] add timeout for http client --- internal/platform/repositories/alert/helper.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/platform/repositories/alert/helper.go b/internal/platform/repositories/alert/helper.go index 44a8778..8a3ca2d 100644 --- a/internal/platform/repositories/alert/helper.go +++ b/internal/platform/repositories/alert/helper.go @@ -7,6 +7,7 @@ import ( "net/http" "strconv" "strings" + "time" "github.com/hatamiarash7/uptime-webhook/internal/models" log "github.com/sirupsen/logrus" @@ -21,7 +22,9 @@ func sendPOSTRequest(url string, payload []byte, version string) (string, error) } // Send the request - client := http.Client{} + client := http.Client{ + Timeout: 5 * time.Second, + } req.Header.Add("Content-Type", "application/json") req.Header.Add("User-Agent", "ArvanCloud-Uptime/"+version) resp, err := client.Do(req)