Documentation ¶
Index ¶
- type RestClient
- func New(host string) RestClient
- func NewInsecure(host string) RestClient
- func NewLocalhost(port string) (rc RestClient)
- func NewWithClient(host string, client *http.Client) RestClient
- func NewWithClientInsecure(host string, client *http.Client) RestClient
- func NewWithTimeout(host string, timeout time.Duration) RestClient
- func (rc *RestClient) Get(path string) (*http.Response, error)
- func (rc *RestClient) Head(path string) (*http.Response, error)
- func (rc *RestClient) Post(path, contentType string, body io.Reader) (*http.Response, error)
- func (rc *RestClient) PostForm(path string, data url.Values) (*http.Response, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type RestClient ¶
type RestClient struct {
// contains filtered or unexported fields
}
RestClient is a wrapper for an http client It also contains a host so all requests go to that post
func New ¶
func New(host string) RestClient
New returns a new rest client that uses the Default HTTP Client witha timeout of x seconds and configures the base url according to the host
func NewInsecure ¶
func NewInsecure(host string) RestClient
NewInsecure returns a new rest client that uses the Default HTTP Client witha timeout of x seconds and configures the base url according to the host Uses HTTP instead of HTTPS
func NewLocalhost ¶
func NewLocalhost(port string) (rc RestClient)
NewLocalhost is a conveniance constructor that makes http calls to localhost using a specific port and http instead of https
func NewWithClient ¶
func NewWithClient(host string, client *http.Client) RestClient
NewWithClient wraps the RestClient around an existing http client (example you could set a timeout)
func NewWithClientInsecure ¶
func NewWithClientInsecure(host string, client *http.Client) RestClient
NewWithClientInsecure is the same as NewWithClient but uses http instead of https
func NewWithTimeout ¶
func NewWithTimeout(host string, timeout time.Duration) RestClient
NewWithTimeout creates a RestClient with a specific timeout
func (*RestClient) Get ¶
func (rc *RestClient) Get(path string) (*http.Response, error)
Get is a wrapper function for http.Client Post function It uses the base url and the path to construct the post url TODO: Make sure authentication and tokens work
func (*RestClient) Head ¶
func (rc *RestClient) Head(path string) (*http.Response, error)
Head is a wrapper function for http.Client Head function It uses the base url and the path to construct the post url TODO: Make sure authentication and tokens work
func (*RestClient) Post ¶
Post is a wrapper function for http.Client Post function It uses the base url and the path to construct the post url TODO: Make sure authentication and tokens work