http

package
v0.0.68 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloneMultipartFileHeader added in v0.0.61

func CloneMultipartFileHeader(fh *multipart.FileHeader) *multipart.FileHeader

func CloneMultipartForm added in v0.0.61

func CloneMultipartForm(f *multipart.Form) *multipart.Form

func CloneOrMakeHeader added in v0.0.61

func CloneOrMakeHeader(hdr http.Header) http.Header

CloneOrMakeHeader invokes Header.Clone but if the result is nil, it'll instead make and return a non-nil Header.

func CloneURL added in v0.0.61

func CloneURL(u *url.URL) *url.URL

func CloneURLValues added in v0.0.61

func CloneURLValues(v url.Values) url.Values

func GetIPFromRequest added in v0.0.29

func GetIPFromRequest(r *http.Request) (net.IP, error)

returns IP address from request. It will lookup IP in X-Forwarded-For and X-Real-IP headers.

Types

type Client

type Client struct {
	http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(options ...ClientOption) (*Client, error)

func (*Client) ApplyOptions

func (o *Client) ApplyOptions(options ...ClientOption) *Client

func (*Client) Get

func (c *Client) Get(url string) ([]byte, error)

func (*Client) Post

func (c *Client) Post(
	url, contentType string,
	headers map[string]string,
	body []byte,
) ([]byte, error)

func (*Client) PostJson added in v0.0.6

func (c *Client) PostJson(
	url string,
	headers map[string]string,
	body []byte,
) ([]byte, error)

func (*Client) PostJsonWithAuthorize added in v0.0.14

func (c *Client) PostJsonWithAuthorize(
	url string,
	headers map[string]string,
	auth func(r *http.Request) error,
	body []byte,
) ([]byte, error)

func (*Client) PostReader

func (c *Client) PostReader(
	url, contentType string,
	headers map[string]string,
	auth func(r *http.Request) error,
	body io.Reader,
) ([]byte, error)

type ClientOption

type ClientOption interface {
	// contains filtered or unexported methods
}

A ClientOption sets options.

func WithDisableKeepAlives

func WithDisableKeepAlives(disableKeepAlives bool) ClientOption

func WithIdleConnTimeout

func WithIdleConnTimeout(idleConnTimeout time.Duration) ClientOption

func WithLogger

func WithLogger(l *log.Logger) ClientOption

WithLogger

func WithMaxIdleConns

func WithMaxIdleConns(maxIdleConns int) ClientOption

func WithResonseHeaderTimeout

func WithResonseHeaderTimeout(responseHeaderTimeout time.Duration) ClientOption

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

type ClientOptionFunc

type ClientOptionFunc func(*Client)

ClientOptionFunc wraps a function that modifies Client into an implementation of the ClientOption interface.

type EmptyClientOption

type EmptyClientOption struct{}

EmptyClientOption does not alter the configuration. It can be embedded in another structure to build custom options.

This API is EXPERIMENTAL.

type EmptyHandlerInterceptorsOption added in v0.0.67

type EmptyHandlerInterceptorsOption struct{}

EmptyHandlerInterceptorsOption does not alter the configuration. It can be embedded in another structure to build custom options.

This API is EXPERIMENTAL.

type HandlerInterceptors added in v0.0.67

type HandlerInterceptors struct {
	Interceptors []func(h http.Handler) http.Handler
}

func NewHandlerInterceptors added in v0.0.67

func NewHandlerInterceptors(opts ...HandlerInterceptorsOption) *HandlerInterceptors

func (*HandlerInterceptors) ApplyOptions added in v0.0.67

type HandlerInterceptorsOption added in v0.0.67

type HandlerInterceptorsOption interface {
	// contains filtered or unexported methods
}

A HandlerInterceptorsOption sets options.

type HandlerInterceptorsOptionFunc added in v0.0.67

type HandlerInterceptorsOptionFunc func(*HandlerInterceptors)

HandlerInterceptorsOptionFunc wraps a function that modifies HandlerInterceptors into an implementation of the HandlerInterceptorsOption interface.

Jump to

Keyboard shortcuts

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