Documentation ¶
Index ¶
- type Client
- 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
- 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, baseURL string) Client
New Client creates a new REST Client.
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, verb, baseURL string) *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'.