http

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultIdleConnectionTimeout = 90 * time.Second

Variables

View Source
var UseFastHttp = true

Functions

This section is empty.

Types

type DefaultHTTPClient

type DefaultHTTPClient struct {
	HTTPClientCommon
	// contains filtered or unexported fields
}

HTTPClient is a reusable HTTP Client.

func NewDefaultHTTPClient

func NewDefaultHTTPClient(host string, debug int, dialTimeout time.Duration, readTimeout time.Duration, writeTimeout time.Duration) *DefaultHTTPClient

NewHTTPClient creates a new HTTPClient.

func (*DefaultHTTPClient) Do

func (w *DefaultHTTPClient) Do(q *Query, opts *HTTPClientDoOptions) (lag float64, err error)

Do performs the action specified by the given Query. It uses fasthttp, and tries to minimize heap allocations.

func (*DefaultHTTPClient) HostString

func (w *DefaultHTTPClient) HostString() string

type FastHTTPClient

type FastHTTPClient struct {
	HTTPClientCommon
	// contains filtered or unexported fields
}

HTTPClient is a reusable HTTP Client.

func NewFastHTTPClient

func NewFastHTTPClient(host string, debug int, dialTimeout time.Duration, readTimeout time.Duration, writeTimeout time.Duration) *FastHTTPClient

NewHTTPClient creates a new HTTPClient.

func (*FastHTTPClient) Do

func (w *FastHTTPClient) Do(q *Query, opts *HTTPClientDoOptions) (lag float64, err error)

Do performs the action specified by the given Query. It uses fasthttp, and tries to minimize heap allocations.

func (*FastHTTPClient) HostString

func (w *FastHTTPClient) HostString() string

type HTTPClient

type HTTPClient interface {
	HostString() string
	Do(q *Query, opts *HTTPClientDoOptions) (lag float64, err error)
}

HTTPClient interface.

func NewHTTPClient

func NewHTTPClient(host string, debug int, dialTimeout time.Duration, readTimeout time.Duration, writeTimeout time.Duration) HTTPClient

type HTTPClientCommon

type HTTPClientCommon struct {
	Host       []byte
	HostString string
	// contains filtered or unexported fields
}

HTTPClient is a reusable HTTP Client.

type HTTPClientDoOptions

type HTTPClientDoOptions struct {
	ContentType          string
	Authorization        string
	Debug                int
	PrettyPrintResponses bool
}

HTTPClientDoOptions wraps options uses when calling `Do`.

type Query

type Query struct {
	HumanLabel       []byte
	HumanDescription []byte
	Method           []byte
	Path             []byte
	Body             []byte
	ID               int64
}

Query holds HTTP request data, typically decoded from the program's input.

func (*Query) String

func (q *Query) String() string

String produces a debug-ready description of a Query.

Jump to

Keyboard shortcuts

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