api

package
v0.0.0-...-82ea29a Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

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 facilitates making HTTP requests to the GitHub API.

func BasicClient

func BasicClient() *Client

BasicClient returns a basic implemenation of a http client.

func NewClient

func NewClient(opts ...ClientOption) *Client

NewClient initializes a Client.

func (Client) GET

func (c Client) GET(version string, data interface{}) error

GET performs a REST request and parses the response.

func (Client) REST

func (c Client) REST(url string, body io.Reader, data interface{}) error

REST performs a REST request and parses the response.

type ClientOption

type ClientOption = func(http.RoundTripper) http.RoundTripper

ClientOption represents an argument to NewClient.

func ReplaceTripper

func ReplaceTripper(tr http.RoundTripper) ClientOption

ReplaceTripper substitutes the underlying RoundTripper with a custom one.

type FakeHTTP

type FakeHTTP struct {
	// Requests stores references to sequential requests that RoundTrip has received
	Requests []*http.Request
	// contains filtered or unexported fields
}

FakeHTTP provides a mechanism by which to stub HTTP responses through.

func (*FakeHTTP) RoundTrip

func (f *FakeHTTP) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip satisfies http.RoundTripper.

func (*FakeHTTP) StubResponse

func (f *FakeHTTP) StubResponse(status int, body io.Reader)

StubResponse pre-records an HTTP response.

func (*FakeHTTP) StubWithFixture

func (f *FakeHTTP) StubWithFixture(status int, fixtureFileName string) func()

StubWithFixture pre-records an HTTP response from a fixture file.

type Tracer

type Tracer struct {
	http.RoundTripper
}

Tracer implements http.RoundTripper. It prints each request and response/error to os.Stderr.

func (*Tracer) RoundTrip

func (t *Tracer) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip calls the nested RoundTripper while printing each request and response/error to os.Stderr on either side of the nested call.

Jump to

Keyboard shortcuts

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