From 49496a5fad9a4bae697d339b3630e9ed1ef4f695 Mon Sep 17 00:00:00 2001 From: "Luis Gustavo S. Barreto" Date: Thu, 8 Aug 2019 16:55:06 -0300 Subject: [PATCH] Uses default host from updatehub settings Signed-off-by: Luis Gustavo S. Barreto --- api.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/api.go b/api.go index 56e0d0f..2195987 100644 --- a/api.go +++ b/api.go @@ -3,12 +3,15 @@ package updatehub import ( "encoding/json" "fmt" + "net/url" "github.com/UpdateHub/updatehub/metadata" "github.com/UpdateHub/updatehub/updatehub" "github.com/parnurzeal/gorequest" ) +var DefaultHost = updatehub.DefaultSettings.ListenSocket + type Client struct { } @@ -93,5 +96,10 @@ func (c *Client) GetLogs() ([]LogEntry, error) { } func buildURL(path string) string { - return fmt.Sprintf("http://localhost:8080/%s", path[1:]) + u, err := url.Parse(DefaultHost) + if err != nil { + panic(err) + } + + return fmt.Sprintf("http://%s/%s", u.Host, path[1:]) }