···1+package util
2+3+import (
4+ "context"
5+)
6+7+type XRPCRequestType int
8+9+const (
10+ Query = XRPCRequestType(iota)
11+ Procedure
12+)
13+14+// API client interface used in lexgen.
15+type LexClient interface {
16+ LexDo(ctx context.Context, kind XRPCRequestType, inpenc string, method string, params map[string]any, bodyobj any, out any) error
17+}
+14-9
xrpc/xrpc.go
···13 "strings"
14 "time"
15016 "github.com/bluesky-social/indigo/util"
17 "github.com/carlmjohnson/versioninfo"
18)
···34 return c.Client
35}
3637-type XRPCRequestType int
000003839type AuthInfo struct {
40 AccessJwt string `json:"accessJwt"`
···110 Reset time.Time
111}
112113-const (
114- Query = XRPCRequestType(iota)
115- Procedure
116-)
117-118// makeParams converts a map of string keys and any values into a URL-encoded string.
119// If a value is a slice of strings, it will be joined with commas.
120// Generally the values will be strings, numbers, booleans, or slices of strings
···133 return params.Encode()
134}
135136-func (c *Client) Do(ctx context.Context, kind XRPCRequestType, inpenc string, method string, params map[string]interface{}, bodyobj interface{}, out interface{}) error {
137 var body io.Reader
138 if bodyobj != nil {
139 if rr, ok := bodyobj.(io.Reader); ok {
···150151 var m string
152 switch kind {
153- case Query:
154 m = "GET"
155- case Procedure:
156 m = "POST"
157 default:
158 return fmt.Errorf("unsupported request kind: %d", kind)
···227228 return nil
229}
0000
···13 "strings"
14 "time"
1516+ lexutil "github.com/bluesky-social/indigo/lex/util"
17 "github.com/bluesky-social/indigo/util"
18 "github.com/carlmjohnson/versioninfo"
19)
···35 return c.Client
36}
3738+type XRPCRequestType = lexutil.XRPCRequestType
39+40+var (
41+ Query = lexutil.Query
42+ Procedure = lexutil.Procedure
43+)
4445type AuthInfo struct {
46 AccessJwt string `json:"accessJwt"`
···116 Reset time.Time
117}
11800000119// makeParams converts a map of string keys and any values into a URL-encoded string.
120// If a value is a slice of strings, it will be joined with commas.
121// Generally the values will be strings, numbers, booleans, or slices of strings
···134 return params.Encode()
135}
136137+func (c *Client) Do(ctx context.Context, kind lexutil.XRPCRequestType, inpenc string, method string, params map[string]interface{}, bodyobj interface{}, out interface{}) error {
138 var body io.Reader
139 if bodyobj != nil {
140 if rr, ok := bodyobj.(io.Reader); ok {
···151152 var m string
153 switch kind {
154+ case lexutil.Query:
155 m = "GET"
156+ case lexutil.Procedure:
157 m = "POST"
158 default:
159 return fmt.Errorf("unsupported request kind: %d", kind)
···228229 return nil
230}
231+232+func (c *Client) LexDo(ctx context.Context, kind lexutil.XRPCRequestType, inpenc string, method string, params map[string]any, bodyobj any, out any) error {
233+ return c.Do(ctx, kind, inpenc, method, params, bodyobj, out)
234+}