httpx

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2019 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(client *http.Client, request *http.Request) (*http.Response, error)

Do makes the given HTTP request using the current requestor

func NewMockResponse

func NewMockResponse(status int, body string) *http.Response

NewMockResponse creates a new mock response

func SetRequestor

func SetRequestor(requestor Requestor)

SetRequestor sets the requestor used by Request

Types

type Requestor

type Requestor interface {
	Do(*http.Client, *http.Request) (*http.Response, error)
}

Requestor is anything that can make an HTTP request with a client

var DefaultRequestor Requestor = defaultRequestor{}

DefaultRequestor is the default HTTP requestor

func NewMockRequestor

func NewMockRequestor(mocks map[string][]*http.Response) Requestor

type Trace

type Trace struct {
	Request       *http.Request
	Response      *http.Response
	Body          []byte
	RequestTrace  []byte
	ResponseTrace []byte
	TimeTaken     time.Duration
}

Trace holds the complete trace of an HTTP request/response

func DoTrace

func DoTrace(client *http.Client, method string, url string, body io.Reader, headers map[string]string) (*Trace, error)

DoTrace makes the given request saving traces of the complete request and response

Jump to

Keyboard shortcuts

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