Documentation ¶
Overview ¶
Package client defines a Wireleap API client.
Index ¶
- func Refresh(req *http.Request) (err error)
- type Client
- func (c *Client) Do(r *http.Request) (*http.Response, error)
- func (c *Client) NewRequest(method string, url string, data interface{}) (*http.Request, error)
- func (c *Client) ParseResponse(res *http.Response, dst interface{}, cs ...string) (err error)
- func (c *Client) Perform(method string, url string, in interface{}, out interface{}, cs ...string) (err error)
- func (c *Client) PerformRequestNoParse(req *http.Request, cs ...string) (res *http.Response, err error)
- func (c *Client) PerformRequestOnce(req *http.Request, out interface{}, cs ...string) (err error)
- func (c *Client) SetInterfaces(is ...interfaces.T)
- func (c *Client) SetTransport(t http.RoundTripper)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
Client is an API client type. It exposes the http.Client interface and it is safe for concurrent use by multiple goroutines. It also encapsulates the keypair used to access the API via its signer.Signer interface.
func New ¶
func New(s signer.Signer, is ...interfaces.T) *Client
New creates a new API client using the given signer to sign API requests.
func NewMock ¶
NewMock creates a new API client which uses a given handler for handling all requests.
func (*Client) NewRequest ¶
NewRequest is a convenience function for creating a new http.Request with a payload that's JSON-marshaled and signed.
func (*Client) ParseResponse ¶ added in v0.2.0
ParseResponse extracts the JSON-encoded payload of a request response and checks for API errors. It is not a method of the Client type since it uses no Client-specific data. Therefore, while low-level, it can be called by code which does not use Client if needed.
func (*Client) Perform ¶
func (c *Client) Perform(method string, url string, in interface{}, out interface{}, cs ...string) (err error)
Perform is a convenience function for creating a new request, performing it and parsing the JSON response into the receiving interface.
func (*Client) PerformRequestNoParse ¶
func (*Client) PerformRequestOnce ¶
func (*Client) SetInterfaces ¶ added in v0.2.0
func (c *Client) SetInterfaces(is ...interfaces.T)
func (*Client) SetTransport ¶
func (c *Client) SetTransport(t http.RoundTripper)