httpcli

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2022 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CopyHeader

func CopyHeader(dst http.Header, src http.Header)

func CtxWithHeader

func CtxWithHeader(ctx context.Context, header http.Header) context.Context

func HeaderFromCtx

func HeaderFromCtx(ctx context.Context) http.Header

func NewRoundTripper

func NewRoundTripper(cfg *TransportOptions) (http.RoundTripper, error)

Types

type BodyReader

type BodyReader interface {
	ReadFrom(r io.Reader) (n int64, err error)
}

type Client

type Client struct {
	http.Client
	Header http.Header
}

Client ...

func NewClient

func NewClient(rt http.RoundTripper) *Client

NewClient ...

func (*Client) Do

func (c *Client) Do(req *http.Request) ([]byte, error)

Do ...

func (*Client) DoWith

func (c *Client) DoWith(req *http.Request, br BodyReader) error

type Error

type Error struct {
	// Code is the HTTP response status code
	Code    int         `json:"code"`
	Message string      `json:"message"`
	Body    string      `json:"body,omitempty"`
	Header  http.Header `json:"header,omitempty"`
}

func (*Error) Error

func (e *Error) Error() string

type Growable

type Growable interface {
	Grow(n int)
}

type TransportOptions

type TransportOptions struct {
	MaxIdleConnsPerHost   int
	InsecureSkipVerify    bool
	DisableHTTP2          bool
	DialTimeout           time.Duration
	ResponseHeaderTimeout time.Duration
	IdleConnTimeout       time.Duration
	ReadIdleTimeout       time.Duration
	PingTimeout           time.Duration
}

Jump to

Keyboard shortcuts

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