Documentation
¶
Overview ¶
Package client defines a Wireleap API client.
Index ¶
- func ParseResponse(res *http.Response, dst interface{}, cs ...string) (err error)
- 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) 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) SetComponent(s string)
- func (c *Client) SetTransport(t http.RoundTripper)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseResponse ¶
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.
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 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) 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) SetComponent ¶
func (*Client) SetTransport ¶
func (c *Client) SetTransport(t http.RoundTripper)