restclient

package module
v0.0.0-...-7554954 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2019 License: Apache-2.0 Imports: 7 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyHTTPParameters = make(HTTPParameters)

EmptyHTTPParameters is a blank HTTPParameters map

Functions

This section is empty.

Types

type HTTPParameters

type HTTPParameters map[string]string

HTTPParameters is a map of strings representing HTTP parameters. These are useful for POST and PUT operations

type IHTTPClient

type IHTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

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

func (c *RestClient) ExecuteRequest(request *http.Request) (*http.Response, error)

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL