Documentation
¶
Index ¶
- Variables
- type HTTPParameters
- type IHTTPClient
- type IRestClient
- type RestClient
- func (c *RestClient) BuildURL(query string) string
- func (c *RestClient) ConvertMapToQueryString(m HTTPParameters) string
- func (c *RestClient) ConvertParametersToReader(parameters HTTPParameters) io.Reader
- func (c *RestClient) CreateRequest(query, method string, body io.Reader, authorization string) (*http.Request, error)
- func (c *RestClient) ExecuteRequest(request *http.Request) (*http.Response, error)
- func (c *RestClient) GetResponseBytes(response *http.Response) []byte
- func (c *RestClient) GetResponseJSON(response *http.Response, receiver interface{}) error
- func (c *RestClient) GetResponseString(response *http.Response) string
Constants ¶
This section is empty.
Variables ¶
var EmptyHTTPParameters = make(HTTPParameters)
EmptyHTTPParameters is a blank HTTPParameters map
Functions ¶
This section is empty.
Types ¶
type HTTPParameters ¶
HTTPParameters is a map of strings representing HTTP parameters. These are useful for POST and PUT operations
type IHTTPClient ¶
IHTTPClient is an interface over the Go HttpClient
type IRestClient ¶
type IRestClient interface {
BuildURL(query string) string
ConvertMapToQueryString(m HTTPParameters) string
ConvertParametersToReader(parameters HTTPParameters) io.Reader
CreateRequest(query, method string, body io.Reader, authorization string) (*http.Request, error)
ExecuteRequest(request *http.Request) (*http.Response, error)
GetResponseBytes(response *http.Response) []byte
GetResponseJSON(response *http.Response, receiver interface{}) error
GetResponseString(response *http.Response) string
}
IRestClient defines an interface for working with RESTful endpoints
type RestClient ¶
type RestClient struct {
BaseURL string
HTTPClient IHTTPClient
}
RestClient provides methods for working with RESTful endpoints
func (*RestClient) BuildURL ¶
func (c *RestClient) BuildURL(query string) string
BuildURL takes a query and builds a full URL
func (*RestClient) ConvertMapToQueryString ¶
func (c *RestClient) ConvertMapToQueryString(m HTTPParameters) string
ConvertMapToQueryString takes a map and converts it to a key/value pairs
func (*RestClient) ConvertParametersToReader ¶
func (c *RestClient) ConvertParametersToReader(parameters HTTPParameters) io.Reader
ConvertParametersToReader takes a set of HTTPParameters and converts them to key/value pairs suitable for use in an HTTP request
func (*RestClient) CreateRequest ¶
func (c *RestClient) CreateRequest(query, method string, body io.Reader, authorization string) (*http.Request, error)
CreateRequest builds a request object for a provided url and HTTP method
func (*RestClient) ExecuteRequest ¶
ExecuteRequest execute an arbitrary request to GoBucket
func (*RestClient) GetResponseBytes ¶
func (c *RestClient) GetResponseBytes(response *http.Response) []byte
GetResponseBytes returns the response content from the body as a byte slice
func (*RestClient) GetResponseJSON ¶
func (c *RestClient) GetResponseJSON(response *http.Response, receiver interface{}) error
GetResponseJSON converts response bytes and unmarshals to a receiver object
func (*RestClient) GetResponseString ¶
func (c *RestClient) GetResponseString(response *http.Response) string
GetResponseString returns the response content from the body as a string