gooseberry: github.com/voicera/gooseberry/web/rest Index | Files

package rest

import "github.com/voicera/gooseberry/web/rest"

Package rest provides REST clients.

Index

Package Files

doc.go form.go json.go noop.go rest.go

type Client Uses

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 Uses

func NewJSONClient(httpClient *http.Client) Client

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

func NewJSONRequestNoopResponseClient Uses

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 Uses

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.

Package rest imports 10 packages (graph). Updated 2018-04-04. Refresh now. Tools for package owners.