Skip to content

Commit

Permalink
use url.Values for /host query parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
chris124567 committed Dec 18, 2024
1 parent 72fdfd5 commit 08e526f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package api

import (
"fmt"
"net/url"
"strconv"

"go.sia.tech/core/consensus"
"go.sia.tech/core/types"
Expand Down Expand Up @@ -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
}

0 comments on commit 08e526f

Please sign in to comment.