rest

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package rest is used internally by the client to interact with the mountebank API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client represents a generic HTTP REST client that handles a JSON structure in requests and responses.

func NewClient

func NewClient(cli *http.Client, root *url.URL) *Client

NewClient returns a new instance of *Client from the provided inner *http.Client httpClient and API base *url.URL baseURL.

func (*Client) DecodeResponseBody

func (cli *Client) DecodeResponseBody(body io.ReadCloser, v interface{}) error

DecodeResponseBody reads a JSON-encoded value from the provided HTTP response body and stores it into the value pointed to by v and closes the body after reading.

func (*Client) Do

func (cli *Client) Do(req *http.Request) (*http.Response, error)

Do sends an HTTP request and returns an HTTP response.

func (*Client) NewRequest

func (cli *Client) NewRequest(ctx context.Context, method, path string, body io.Reader, q url.Values) (*http.Request, error)

NewRequest builds the specified *http.Request value from the provided request method, path, body and optional body/query parameters, with the appropriate headers set depending on the particular request method.

Jump to

Keyboard shortcuts

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