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