Documentation ¶
Index ¶
- type Client
- type ClientConfig
- type HTTPClient
- type Request
- func (r *Request) AddHeader(key, value string) *Request
- func (r *Request) Body(v interface{}) *Request
- func (r *Request) Do() Response
- func (r *Request) QueryParams(params interface{}) *Request
- func (r *Request) Resource(resource string) *Request
- func (r *Request) ResourceID(resourceID string) *Request
- func (r *Request) SetHeader(key, value string) *Request
- type Response
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface { Verb(verb string) *Request Post() *Request Get() *Request Put() *Request Delete() *Request }
Client is the interface of a rest client that can build requests for the different http verbs.
func NewClient ¶
func NewClient(httpClient HTTPClient, clientConfig ClientConfig) Client
New Client creates a new REST Client.
type ClientConfig ¶ added in v1.0.11
type HTTPClient ¶
HTTPClient is the interface of an http client that is compatible with *http.Client.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request is a wrapper for preparing and sending a *http.Request. It provides funtionality for encoding arbitrary types to the wire format and back.
func NewRequest ¶
func NewRequest(client HTTPClient, config ClientConfig) *Request
NewRequest creates a new *Request which uses client to send out the prepared *http.Request.
func (*Request) Do ¶
Do sends the request. This is a no-op if there were errors while building the request.
func (*Request) QueryParams ¶
QueryParams sets the request's query parameters.
func (*Request) Resource ¶
Resource sets the API resource which the request should be built for, e.g. 'monitors'. The resulting API resource path for this would be '/api/monitors'.
func (*Request) ResourceID ¶
ResourceID sets the API resource ID which the request should be built for, e.g. '123'. Example: if the resource was set to 'monitors', the resulting API resource path will be '/api/monitors/123'.
func (*Request) SetHeader ¶ added in v1.0.55
SetHeader adds an HTTP header to the request. - Does not append if the header key is already present. Added this method to include API specific headers. (eg) When HeartBeat threshold API version is 2 We invoke SetHeader("Accept", "application/json; version=2") in API implementation.