Documentation
¶
Overview ¶
package client provides functionality for building HTTP clients.
Recommended Usage:
type MyClient struct {
Client *client.Client
}
type ThingInput struct {
}
type ThingOutput struct {
}
func(c MyClient) Thing(input *ThingInput) (*ThingOutput, err) {
var output ThingOutput
req := c.Client.NewRequest("GET", "/thing", input, output)
err := req.Send()
return output, err
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DebugLogging ¶
func DebugLogging(c *Client)
DebugLogging adds logging of the enitre request and response.
Types ¶
type Client ¶
type Client struct {
Info metadata.ClientInfo // Metadata about this client.
HTTPClient *http.Client // Underlying http.Client used to make requests.
Handlers request.Handlers // Handlers to use with requests generated by this client.
}
Client is a request builder.
func New ¶
func New(info metadata.ClientInfo, options ...ClientOpt) *Client
New returns a new client with default Handlers and http client.
func (*Client) NewRequest ¶
func (c *Client) NewRequest(ctx context.Context, method, path string, params interface{}, data interface{}) *request.Request
NewRequest builds a request from the client configuration. An http.Request will be initialized with the given context, method and path. A request.Request will be initialized with the http.Request, Handlers, params and data.
type ClientOpt ¶
type ClientOpt func(*Client)
ClientOpt represents a function that will alter the configuration of a Client.
func RequestSigning ¶
RequestSigning adds a handler to sign requests.
func RoundTripper ¶
func RoundTripper(r http.RoundTripper) ClientOpt
RoundTripper sets a custom transport on the underlying http Client.