Documentation
¶
Index ¶
- type HTTPClient
- type HTTPClientInterface
- type JSONClient
- func (c JSONClient) DELETE(path string, successReceiver, errorReceiver interface{}) (*http.Response, error)
- func (c JSONClient) GET(path string, successReceiver, errorReceiver interface{}) (*http.Response, error)
- func (c JSONClient) POST(path string, body, successReceiver, errorReceiver interface{}) (*http.Response, error)
- func (c JSONClient) PUT(path string, body, successReceiver, errorReceiver interface{}) (*http.Response, error)
- func (c JSONClient) WithAuthorization(auth string) RESTClient
- type MockHTTPClient
- type MockRESTClient
- func (m MockRESTClient) DELETE(path string, successReceiver, errorReceiver interface{}) (bool, error)
- func (m MockRESTClient) GET(path string, successReceiver, errorReceiver interface{}) (bool, error)
- func (m MockRESTClient) POST(path string, body, successReceiver, errorReceiver interface{}) (bool, error)
- func (m MockRESTClient) PUT(path string, body, successReceiver, errorReceiver interface{}) (bool, error)
- func (m MockRESTClient) WithAuthorization(auth string) RESTClient
- type RESTClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPClient ¶
HTTPClient implements methods as a wrapper over the Go HttpClient
func (*HTTPClient) SetTransport ¶
func (h *HTTPClient) SetTransport(transport *http.Transport)
SetTransport sets the transport information for this HTTP client
type HTTPClientInterface ¶
HTTPClientInterface is an interface over the Go HttpClient
type JSONClient ¶
type JSONClient struct { BaseURL string HTTPClient HTTPClientInterface // contains filtered or unexported fields }
JSONClient provides a set of methods for working with RESTful endpoints that accept and return JSON data
func NewJSONClient ¶
func NewJSONClient(baseURL string, httpClient HTTPClientInterface) JSONClient
NewJSONClient creates a new JSON-based REST client
func (JSONClient) DELETE ¶
func (c JSONClient) DELETE(path string, successReceiver, errorReceiver interface{}) (*http.Response, error)
DELETE performs an HTTP DELETE operation. You provide a path, which should exclude the TLD, as this is defined in BaseURL. If your request requires authorization call WithAuthorization first, then DELETE.
If some type of error occurs when creating the request, executing the request, or unmarshalling the response, err will be populated. The http.Response is returned so callers can inspect the status.
func (JSONClient) GET ¶
func (c JSONClient) GET(path string, successReceiver, errorReceiver interface{}) (*http.Response, error)
GET performs an HTTP GET operation. You provide a path, which should exclude the the TLD, as this is defined in BaseURL. If your request requires authorization call WithAuthorization first, then GET.
If some type of error occurs when creating the request, executing the request, or unmarshalling the response, err will be populated. The http.Response is returned so callers can inspect the status.
func (JSONClient) POST ¶
func (c JSONClient) POST(path string, body, successReceiver, errorReceiver interface{}) (*http.Response, error)
POST performs an HTTP POST operation. You provide a path, which should exclude the the TLD, as this is defined in BaseURL. If your request requires authorization call WithAuthorization first, then POST.
If some type of error occurs when creating the request, executing the request, or unmarshalling the response, err will be populated. The http.Response is returned so callers can inspect the status.
func (JSONClient) PUT ¶
func (c JSONClient) PUT(path string, body, successReceiver, errorReceiver interface{}) (*http.Response, error)
PUT performs an HTTP PUT operation. You provide a path, which should exclude the the TLD, as this is defined in BaseURL. If your request requires authorization call WithAuthorization first, then PUT.
If some type of error occurs when creating the request, executing the request, or unmarshalling the response, err will be populated. The http.Response is returned so callers can inspect the status.
func (JSONClient) WithAuthorization ¶
func (c JSONClient) WithAuthorization(auth string) RESTClient
WithAuthorization returns an instance of RESTClient with an authorization header set
type MockHTTPClient ¶
type MockHTTPClient struct { DoFunc func(req *http.Request) (*http.Response, error) SetTransportFunc func(transport *http.Transport) }
MockHTTPClient is a mock HTTP client
func (*MockHTTPClient) SetTransport ¶
func (m *MockHTTPClient) SetTransport(transport *http.Transport)
SetTransport mocks the SetTransport method
type MockRESTClient ¶
type MockRESTClient struct { DELETEFunc func(path string, successReceiver, errorReceiver interface{}) (bool, error) GETFunc func(path string, successReceiver, errorReceiver interface{}) (bool, error) POSTFunc func(path string, body, successReceiver, errorReceiver interface{}) (bool, error) PUTFunc func(path string, body, successReceiver, errorReceiver interface{}) (bool, error) WithAuthorizationFunc func(auth string) RESTClient }
MockRESTClient is a mock for RESTClient
func (MockRESTClient) DELETE ¶
func (m MockRESTClient) DELETE(path string, successReceiver, errorReceiver interface{}) (bool, error)
DELETE is a mock method
func (MockRESTClient) GET ¶
func (m MockRESTClient) GET(path string, successReceiver, errorReceiver interface{}) (bool, error)
GET is a mock method
func (MockRESTClient) POST ¶
func (m MockRESTClient) POST(path string, body, successReceiver, errorReceiver interface{}) (bool, error)
POST is a mock method
func (MockRESTClient) PUT ¶
func (m MockRESTClient) PUT(path string, body, successReceiver, errorReceiver interface{}) (bool, error)
PUT is a mock method
func (MockRESTClient) WithAuthorization ¶
func (m MockRESTClient) WithAuthorization(auth string) RESTClient
WithAuthorization is a mock method
type RESTClient ¶
type RESTClient interface { DELETE(path string, successReceiver, errorReceiver interface{}) (*http.Response, error) GET(path string, successReceiver, errorReceiver interface{}) (*http.Response, error) POST(path string, body, successReceiver, errorReceiver interface{}) (*http.Response, error) PUT(path string, body, successReceiver, errorReceiver interface{}) (*http.Response, error) WithAuthorization(auth string) RESTClient }
RESTClient defines an interface for working with RESTful endpoints