fix: add a timeout to the http client (#125)

Carlos Alexandro Becker created

Signed-off-by: Carlos Alexandro Becker <caarlos0@users.noreply.github.com>

Change summary

pkg/catwalk/client.go | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

Detailed changes

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,
+		},
 	}
 }