From 08e526f36d76798e9ccbb8699ee778d311271e15 Mon Sep 17 00:00:00 2001 From: Christopher Tarry Date: Wed, 18 Dec 2024 14:51:30 -0500 Subject: [PATCH] use url.Values for /host query parameters --- api/client.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/api/client.go b/api/client.go index 281f987..c9e0622 100644 --- a/api/client.go +++ b/api/client.go @@ -2,6 +2,8 @@ package api import ( "fmt" + "net/url" + "strconv" "go.sia.tech/core/consensus" "go.sia.tech/core/types" @@ -267,6 +269,11 @@ func (c *Client) Search(id types.Hash256) (resp explorer.SearchType, err error) // HostsList searches the hosts by the given criteria. func (c *Client) HostsList(params explorer.HostQuery, sortBy explorer.HostSortColumn, dir explorer.HostSortDir, offset, limit uint64) (resp []explorer.Host, err error) { - err = c.c.POST(fmt.Sprintf("/hosts?sort=%s&dir=%s&offset=%d&limit=%d", sortBy, dir, offset, limit), params, &resp) + v := url.Values{} + v.Add("sort", string(sortBy)) + v.Add("dir", string(dir)) + v.Add("offset", strconv.FormatUint(offset, 10)) + v.Add("limit", strconv.FormatUint(limit, 10)) + err = c.c.POST("/hosts?"+v.Encode(), params, &resp) return }