rest

package
v0.0.0-...-dc23390 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2018 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package rest provides REST clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	// WithBaseURL configures the client with a base URL; returns modified self.
	WithBaseURL(baseURL string) Client

	// Get makes a GET request.
	Get(url string, body interface{}, result interface{}) (*http.Response, error)

	// Head makes a HEAD request.
	Head(url string, body interface{}, result interface{}) (*http.Response, error)

	// Post makes a POST request.
	Post(url string, body interface{}, result interface{}) (*http.Response, error)

	// Put makes a PUT request.
	Put(url string, body interface{}, result interface{}) (*http.Response, error)

	// Patch makes a PATCH request.
	Patch(url string, body interface{}, result interface{}) (*http.Response, error)

	// Delete makes a DELETE request.
	Delete(url string, body interface{}, result interface{}) (*http.Response, error)

	// Do makes a REST request using JSON for input and output.
	Do(method string, url string, body interface{}, result interface{}) (*http.Response, error)
}

Client represts a web client to use with REST APIs.

func NewJSONClient

func NewJSONClient(httpClient *http.Client) Client

NewJSONClient creates a new REST client that uses JSON to encode requests and decode responses.

func NewJSONRequestNoopResponseClient

func NewJSONRequestNoopResponseClient(httpClient *http.Client) Client

NewJSONRequestNoopResponseClient creates a new REST client that uses JSON to encode requests and does not decode the response (it leaves the decoding to the caller, which has access to the response object).

func NewURLEncodedRequestJSONResponseClient

func NewURLEncodedRequestJSONResponseClient(httpClient *http.Client) Client

NewURLEncodedRequestJSONResponseClient creates a new REST client that URL-encodes requests and uses JSON to decode responses. The body parameter for this client's methods must be a map[string]string instance.

Jump to

Keyboard shortcuts

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