http

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultClient = http.DefaultClient

DefaultClient is the default HTTP client

Functions

This section is empty.

Types

type Client

type Client interface {
	Do(context.Context, *Request) (*Response, error)
}

Client is the interface of a http client

type DefaultTracer

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

DefaultTracer stores http request timings

func (*DefaultTracer) Done added in v0.1.6

func (t *DefaultTracer) Done()

func (*DefaultTracer) Timings

func (t *DefaultTracer) Timings() Timings

Timings computes and returns the timings for a request

func (*DefaultTracer) Tracer

func (t *DefaultTracer) Tracer() *httptrace.ClientTrace

Tracer returns a new httptrace.ClientTrace

type Request

type Request struct {
	*http.Request

	SkipVerify bool
}

Request is a http request

func NewRequest

func NewRequest(verb string, url string, body io.Reader) (*Request, error)

NewRequest is a helper to quickly create a new http request

type Response

type Response struct {
	StatusCode int
	Header     map[string][]string
	Body       []byte
	Timings    Timings
}

Response a http response with added timing information

type TimedClient

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

TimedClient adds http request timings as part of the http response

func NewTimedClient

func NewTimedClient(client *http.Client) *TimedClient

NewTimedClient creates a default timed client

func (TimedClient) Do

func (c TimedClient) Do(ctx context.Context, req *Request) (*Response, error)

Do executes a http request

type Timings

type Timings struct {
	DNSLookup,
	TCPConnection,
	TLSHandshake,
	ServerProcessing,
	ContentTransfer time.Duration
}

Timings holds the timings data for a http request

type Tracer

type Tracer interface {
	Tracer() *httptrace.ClientTrace
	Timings() Timings
	// Done needs to be called when the request is finished.
	// Without calling done the ContentTransfer in the Timings will be invalid.
	Done()
}

Tracer is the interface for a tracer

Jump to

Keyboard shortcuts

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