httpclient

package
v0.0.0-...-f6843db Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MIMEJSON              = "application/json"
	MIMEHTML              = "text/html"
	MIMEXML               = "application/xml"
	MIMEXML2              = "text/xml"
	MIMEPlain             = "text/plain"
	MIMEPOSTForm          = "application/x-www-form-urlencoded"
	MIMEMultipartPOSTForm = "multipart/form-data"
	MIMEPROTOBUF          = "application/x-protobuf"
	MIMEMSGPACK           = "application/x-msgpack"
	MIMEMSGPACK2          = "application/msgpack"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Dial            xtime.Duration
	Timeout         xtime.Duration
	KeepAlive       xtime.Duration
	MaxConns        int
	MaxIdle         int
	BackoffInterval xtime.Duration // Interval is second
	// contains filtered or unexported fields
}

type HttpClient

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

func NewHTTPClient

func NewHTTPClient(c *Config) *HttpClient

NewHTTPClient returns a new instance of httpClient

func (*HttpClient) Delete

func (c *HttpClient) Delete(ctx context.Context, url, contentType string, headers xhttp.Header, param, res interface{}) (err error)

Delete makes a HTTP DELETE request to provided URL with context passed in

func (*HttpClient) Do

func (c *HttpClient) Do(ctx context.Context, req *xhttp.Request, res interface{}) (err error)

Do makes an HTTP request with the native `http.Do` interface and context passed in

func (*HttpClient) Get

func (c *HttpClient) Get(ctx context.Context, url string, headers xhttp.Header, res interface{}) (err error)

Get makes a HTTP GET request to provided URL with context passed in

func (*HttpClient) Patch

func (c *HttpClient) Patch(ctx context.Context, url, contentType string, headers xhttp.Header, param, res interface{}) (err error)

Patch makes a HTTP PATCH request to provided URL with context passed in

func (*HttpClient) Post

func (c *HttpClient) Post(ctx context.Context, url, contentType string, headers xhttp.Header, param, res interface{}) (err error)

Post makes a HTTP POST request to provided URL with context passed in

func (*HttpClient) Put

func (c *HttpClient) Put(ctx context.Context, url, contentType string, headers xhttp.Header, param, res interface{}) (err error)

Put makes a HTTP PUT request to provided URL with context passed in

func (*HttpClient) SetRetrier

func (c *HttpClient) SetRetrier(retrier retry.Retriable)

SetRetryCount sets the retry count for the httpClient

func (*HttpClient) SetRetryCount

func (c *HttpClient) SetRetryCount(count int)

SetRetryCount sets the retry count for the httpClient

Jump to

Keyboard shortcuts

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