httpclient

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PATH        = "path"
	URL         = "url"
	BASEURL     = "base_url"
	METHOD      = "method"
	BODY        = "body"
	HEADER      = "header"
	QUERYPARAMS = "query_params"

	SCHEME = "scheme"
	HOST   = "host"
)

Variables

View Source
var (
	DefaultFastHttpClient = &fasthttp.Client{
		ReadTimeout:         time.Second * 10,
		WriteTimeout:        time.Second * 10,
		MaxIdleConnDuration: time.Minute,
	}
)
View Source
var (
	DefaultNetHttpClient = &http.Client{
		Timeout: time.Second * 10,
		Transport: &http.Transport{
			MaxIdleConnsPerHost: 1024,
			TLSHandshakeTimeout: 0 * time.Second,
		},
	}
)

Functions

func GetSubscriptionInput

func GetSubscriptionInput(input []byte) (url, header, body []byte)

func NewRequestWithContext

func NewRequestWithContext(ctx context.Context, method, url string, body io.Reader) (*http.Request, error)

func SetInputBody

func SetInputBody(input, body []byte) []byte

func SetInputBodyWithPath

func SetInputBodyWithPath(input, body []byte, path string) []byte

func SetInputHeader

func SetInputHeader(input, headers []byte) []byte

func SetInputHost

func SetInputHost(input, host []byte) []byte

func SetInputMethod

func SetInputMethod(input, method []byte) []byte

func SetInputPath

func SetInputPath(input, path []byte) []byte

func SetInputQueryParams

func SetInputQueryParams(input, queryParams []byte) []byte

func SetInputScheme

func SetInputScheme(input, scheme []byte) []byte

func SetInputURL

func SetInputURL(input, url []byte) []byte

Types

type Client

type Client interface {
	Do(ctx context.Context, requestInput []byte, out io.Writer) (err error)
}

type FastHttpClient

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

func NewFastHttpClient

func NewFastHttpClient(client *fasthttp.Client, options ...Option) *FastHttpClient

func (*FastHttpClient) Do

func (f *FastHttpClient) Do(ctx context.Context, requestInput []byte, out io.Writer) (err error)

type NetHttpClient

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

func NewNetHttpClient

func NewNetHttpClient(client *http.Client) *NetHttpClient

func (*NetHttpClient) Do

func (n *NetHttpClient) Do(ctx context.Context, requestInput []byte, out io.Writer) (err error)

type Option

type Option func(c *FastHttpClient)

func WithLogger

func WithLogger(logger abstractlogger.Logger) Option

Jump to

Keyboard shortcuts

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