+9
-3
atproto/client/api_client.go
+9
-3
atproto/client/api_client.go
···
6
6
"encoding/json"
7
7
"fmt"
8
8
"net/http"
9
-
"net/url"
10
9
11
10
"github.com/bluesky-social/indigo/atproto/syntax"
12
11
)
···
44
43
// High-level helper for simple JSON "Query" API calls.
45
44
//
46
45
// Does not work with all API endpoints. For more control, use the Do() method with APIRequest.
47
-
func (c *APIClient) Get(ctx context.Context, endpoint syntax.NSID, params url.Values, out any) error {
46
+
func (c *APIClient) Get(ctx context.Context, endpoint syntax.NSID, params map[string]any, out any) error {
48
47
49
48
req := NewAPIRequest(http.MethodGet, endpoint, nil)
50
-
req.QueryParams = params
51
49
req.Headers.Set("Accept", "application/json")
50
+
51
+
if params != nil {
52
+
qp, err := ParseParams(params)
53
+
if err != nil {
54
+
return err
55
+
}
56
+
req.QueryParams = qp
57
+
}
52
58
53
59
resp, err := c.Do(ctx, req)
54
60
if err != nil {
+6
-6
atproto/client/cmd/atclient/main.go
+6
-6
atproto/client/cmd/atclient/main.go
···
108
108
}
109
109
110
110
func simpleGet(ctx context.Context, c *client.APIClient) error {
111
-
params := map[string][]string{
112
-
"actor": []string{"atproto.com"},
113
-
"limit": []string{"2"},
114
-
"includePins": []string{"false"},
111
+
params := map[string]any{
112
+
"actor": "atproto.com",
113
+
"limit": 2,
114
+
"includePins": false,
115
115
}
116
116
117
117
var d json.RawMessage
···
192
192
c := client.NewAdminClient(cctx.String("host"), cctx.String("admin-password"))
193
193
194
194
var d json.RawMessage
195
-
params := map[string][]string{
196
-
"did": []string{cctx.String("did")},
195
+
params := map[string]any{
196
+
"did": cctx.String("did"),
197
197
}
198
198
if err := c.Get(ctx, "com.atproto.admin.getAccountInfo", params, &d); err != nil {
199
199
return err
+2
-2
atproto/client/examples_test.go
+2
-2
atproto/client/examples_test.go
···
17
17
}
18
18
19
19
endpoint := syntax.NSID("app.bsky.actor.getProfile")
20
-
params := map[string][]string{
21
-
"actor": []string{"atproto.com"},
20
+
params := map[string]any{
21
+
"actor": "atproto.com",
22
22
}
23
23
var profile appbsky.ActorDefs_ProfileViewDetailed
24
24
if err := c.Get(ctx, endpoint, params, &profile); err != nil {