From 650179c7111e7e57a714da0275d8074aee0d2cf7 Mon Sep 17 00:00:00 2001 From: Carlos Alexandro Becker Date: Fri, 12 Dec 2025 09:54:49 -0300 Subject: [PATCH] fix: add a timeout to the http client (#125) Signed-off-by: Carlos Alexandro Becker --- pkg/catwalk/client.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/pkg/catwalk/client.go b/pkg/catwalk/client.go index c43fc87972fa90e91fefaa5311af8aa8f8a2003a..9cdd24029ab58ac99dba308e12155cd116677ad8 100644 --- a/pkg/catwalk/client.go +++ b/pkg/catwalk/client.go @@ -7,6 +7,7 @@ import ( "fmt" "net/http" "os" + "time" xetag "github.com/charmbracelet/x/etag" ) @@ -22,17 +23,16 @@ type Client struct { // New creates a new client instance // Uses CATWALK_URL environment variable or falls back to localhost:8080. func New() *Client { - return &Client{ - baseURL: cmp.Or(os.Getenv("CATWALK_URL"), defaultURL), - httpClient: &http.Client{}, - } + return NewWithURL(cmp.Or(os.Getenv("CATWALK_URL"), defaultURL)) } // NewWithURL creates a new client with a specific URL. func NewWithURL(url string) *Client { return &Client{ - baseURL: url, - httpClient: &http.Client{}, + baseURL: url, + httpClient: &http.Client{ + Timeout: 30 * time.Second, + }, } }