Documentation
¶
Index ¶
- type BodyProvider
- type Client
- func (s *Client) Add(key, value string) *Client
- func (s *Client) Base(rawURL string) *Client
- func (s *Client) Body(body io.Reader) *Client
- func (s *Client) BodyForm(bodyForm interface{}) *Client
- func (s *Client) BodyJSON(bodyJSON interface{}) *Client
- func (s *Client) BodyProvider(body BodyProvider) *Client
- func (s *Client) Client(httpClient *http.Client) *Client
- func (s *Client) Connect(pathURL string) *Client
- func (s *Client) Delete(pathURL string) *Client
- func (s *Client) Do(req *http.Request, successV, failureV interface{}) (*http.Response, error)
- func (s *Client) Doer(doer Doer) *Client
- func (s *Client) Get(pathURL string) *Client
- func (s *Client) Head(pathURL string) *Client
- func (s *Client) New() *Client
- func (s *Client) Options(pathURL string) *Client
- func (s *Client) Patch(pathURL string) *Client
- func (s *Client) Path(path string) *Client
- func (s *Client) Post(pathURL string) *Client
- func (s *Client) Put(pathURL string) *Client
- func (s *Client) QueryStruct(queryStruct interface{}) *Client
- func (s *Client) Receive(ctx context.Context, successV, failureV interface{}) (*http.Response, error)
- func (s *Client) ReceiveSuccess(ctx context.Context, successV interface{}) (*http.Response, error)
- func (s *Client) Request(ctx context.Context) (*http.Request, error)
- func (s *Client) ResponseDecoder(decoder ResponseDecoder) *Client
- func (s *Client) Set(key, value string) *Client
- func (s *Client) SetBasicAuth(username, password string) *Client
- func (s *Client) SignProvider(signer SignerProvider) *Client
- func (s *Client) Trace(pathURL string) *Client
- type Doer
- type HMACSigner
- type ResponseDecoder
- type SignerProvider
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BodyProvider ¶
type BodyProvider interface {
// ContentType returns the Content-Type of the body.
ContentType() string
// Body returns the io.Reader body.
Body() (io.Reader, error)
}
BodyProvider provides Body content for http.Request attachment.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an HTTP Request builder and sender.
func (*Client) Add ¶
Add adds the key, value pair in Headers, appending values for existing keys to the key's values. Header keys are canonicalized.
func (*Client) Body ¶
Body sets the Client's body. The body is used on new requests (see Request()).
func (*Client) BodyProvider ¶
func (s *Client) BodyProvider(body BodyProvider) *Client
BodyProvider sets the Client's body provider.
func (*Client) Client ¶
Client sets the http Client used to do requests. If a nil client is given, the http.DefaultClient will be used.
func (*Client) Doer ¶
Doer sets the custom Doer implementation used to do requests. If a nil client is given, the http.DefaultClient will be used.
func (*Client) New ¶
New returns a copy of a Client for creating a new Client with properties from a parent Client.
func (*Client) Path ¶
Path extends the rawURL with the given path by resolving the reference to an absolute URL. If parsing errors occur, the rawURL is left unmodified.
func (*Client) QueryStruct ¶
QueryStruct appends the queryStruct to the Client's queryStructs. The
func (*Client) Receive ¶
func (s *Client) Receive(ctx context.Context, successV, failureV interface{}) (*http.Response, error)
Receive creates a new HTTP request and returns the response. Success responses
func (*Client) ReceiveSuccess ¶
ReceiveSuccess creates a new HTTP request and returns the response. Success
func (*Client) ResponseDecoder ¶
func (s *Client) ResponseDecoder(decoder ResponseDecoder) *Client
ResponseDecoder sets the Client's response decoder.
func (*Client) Set ¶
Set sets the key, value pair in Headers, replacing existing values associated with key. Header keys are canonicalized.
func (*Client) SetBasicAuth ¶
SetBasicAuth sets the Authorization header to use HTTP Basic Authentication
func (*Client) SignProvider ¶
func (s *Client) SignProvider(signer SignerProvider) *Client
SignProvider sets the Client's SignerProvider.
type Doer ¶
Doer executes http requests. It is implemented by *http.Client. You can wrap *http.Client with layers of Doers to form a stack of client-side middleware.
type HMACSigner ¶
type HMACSigner struct {
Key string
}
HMACSigner signs requests with an HMAC signature.
func NewHMacSigner ¶
func NewHMacSigner(key string) *HMACSigner
NewHMacSigner returns a new HMACSigner.
type ResponseDecoder ¶
type ResponseDecoder interface {
// Decode decodes the response into the value pointed to by v.
Decode(resp *http.Response, v interface{}) error
}
ResponseDecoder decodes http responses into struct values.
type SignerProvider ¶
SignProvid provides a Signer for requests.