fork of indigo with slightly nicer lexgen

switch to using net/http consts for request types

Changed files
+11 -15
lex
util
xrpc
+4 -5
lex/util/client.go
··· 2 2 3 3 import ( 4 4 "context" 5 + "net/http" 5 6 ) 6 - 7 - type XRPCRequestType int 8 7 9 8 const ( 10 - Query = XRPCRequestType(iota) 11 - Procedure 9 + Query = http.MethodGet 10 + Procedure = http.MethodPost 12 11 ) 13 12 14 13 // API client interface used in lexgen. 15 14 type LexClient interface { 16 - LexDo(ctx context.Context, kind XRPCRequestType, inpenc string, method string, params map[string]any, bodyobj any, out any) error 15 + LexDo(ctx context.Context, kind string, inpenc string, method string, params map[string]any, bodyobj any, out any) error 17 16 }
+7 -10
xrpc/xrpc.go
··· 13 13 "strings" 14 14 "time" 15 15 16 - lexutil "github.com/bluesky-social/indigo/lex/util" 17 16 "github.com/bluesky-social/indigo/util" 18 17 "github.com/carlmjohnson/versioninfo" 19 18 ) ··· 35 34 return c.Client 36 35 } 37 36 38 - type XRPCRequestType = lexutil.XRPCRequestType 39 - 40 37 var ( 41 - Query = lexutil.Query 42 - Procedure = lexutil.Procedure 38 + Query = http.MethodGet 39 + Procedure = http.MethodPost 43 40 ) 44 41 45 42 type AuthInfo struct { ··· 134 131 return params.Encode() 135 132 } 136 133 137 - func (c *Client) Do(ctx context.Context, kind lexutil.XRPCRequestType, inpenc string, method string, params map[string]interface{}, bodyobj interface{}, out interface{}) error { 134 + func (c *Client) Do(ctx context.Context, kind string, inpenc string, method string, params map[string]interface{}, bodyobj interface{}, out interface{}) error { 138 135 var body io.Reader 139 136 if bodyobj != nil { 140 137 if rr, ok := bodyobj.(io.Reader); ok { ··· 151 148 152 149 var m string 153 150 switch kind { 154 - case lexutil.Query: 151 + case Query: 155 152 m = "GET" 156 - case lexutil.Procedure: 153 + case Procedure: 157 154 m = "POST" 158 155 default: 159 - return fmt.Errorf("unsupported request kind: %d", kind) 156 + return fmt.Errorf("unsupported request kind: %s", kind) 160 157 } 161 158 162 159 var paramStr string ··· 229 226 return nil 230 227 } 231 228 232 - func (c *Client) LexDo(ctx context.Context, kind lexutil.XRPCRequestType, inpenc string, method string, params map[string]any, bodyobj any, out any) error { 229 + func (c *Client) LexDo(ctx context.Context, kind string, inpenc string, method string, params map[string]any, bodyobj any, out any) error { 233 230 return c.Do(ctx, kind, inpenc, method, params, bodyobj, out) 234 231 }