From b3f988eedad37c091ebe1bf943a6280ad6c6907d Mon Sep 17 00:00:00 2001 From: dushanlk Date: Sat, 4 Jan 2025 11:34:32 +0530 Subject: [PATCH] Added request timeout for scraping and url status checks --- handlers/scrape.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/handlers/scrape.go b/handlers/scrape.go index 26fd6d1..d174449 100644 --- a/handlers/scrape.go +++ b/handlers/scrape.go @@ -7,6 +7,7 @@ import ( "net/url" "strconv" "strings" + "time" "scraper/config" "scraper/logger" @@ -25,6 +26,7 @@ func ScrapeHandler(context *gin.Context) { Transport: &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // Disable TLS verification }, + Timeout: 30 * time.Second, } if baseURL == "" { @@ -68,6 +70,7 @@ func PageHandler(context *gin.Context) { Transport: &http.Transport{ TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, // Disable TLS verification }, + Timeout: 10 * time.Second, } // Request ID is required to fetch infromation from the in-memory storage. requestID := context.Param("id")