Documentation
¶
Index ¶
- func NewNativeHttpClient(properties *HttpClientProperties) (*http.Client, error)
- type ContextualHttpClient
- type DefaultHttpClient
- func (d *DefaultHttpClient) Delete(url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
- func (d *DefaultHttpClient) Get(url string, result interface{}, options ...RequestOption) (*HttpResponse, error)
- func (d *DefaultHttpClient) Patch(url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
- func (d *DefaultHttpClient) Post(url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
- func (d *DefaultHttpClient) Put(url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
- func (d *DefaultHttpClient) Request(method string, url string, body interface{}, result interface{}, ...) (*HttpResponse, error)
- type HttpClient
- type HttpClientProperties
- type HttpResponse
- type HttpSeries
- type ProxyProperties
- type RequestOption
- type RequestReader
- type TraceableHttpClient
- func (t *TraceableHttpClient) Delete(ctx context.Context, url string, body interface{}, result interface{}, ...) (*HttpResponse, error)
- func (t *TraceableHttpClient) Get(ctx context.Context, url string, result interface{}, options ...RequestOption) (*HttpResponse, error)
- func (t *TraceableHttpClient) Patch(ctx context.Context, url string, body interface{}, result interface{}, ...) (*HttpResponse, error)
- func (t *TraceableHttpClient) Post(ctx context.Context, url string, body interface{}, result interface{}, ...) (*HttpResponse, error)
- func (t *TraceableHttpClient) Put(ctx context.Context, url string, body interface{}, result interface{}, ...) (*HttpResponse, error)
- func (t *TraceableHttpClient) Request(ctx context.Context, method string, url string, body interface{}, ...) (*HttpResponse, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewNativeHttpClient ¶
func NewNativeHttpClient(properties *HttpClientProperties) (*http.Client, error)
Types ¶
type ContextualHttpClient ¶
type ContextualHttpClient interface {
Get(ctx context.Context, url string, result interface{}, options ...RequestOption) (*HttpResponse, error)
Post(ctx context.Context, url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
Put(ctx context.Context, url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
Patch(ctx context.Context, url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
Delete(ctx context.Context, url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
Request(ctx context.Context, method string, url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
}
func NewTraceableHttpClient ¶
func NewTraceableHttpClient(client HttpClient, appProps *config.AppProperties) ContextualHttpClient
type DefaultHttpClient ¶
type DefaultHttpClient struct {
// contains filtered or unexported fields
}
func (*DefaultHttpClient) Delete ¶
func (d *DefaultHttpClient) Delete(url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
func (*DefaultHttpClient) Get ¶
func (d *DefaultHttpClient) Get(url string, result interface{}, options ...RequestOption) (*HttpResponse, error)
func (*DefaultHttpClient) Patch ¶
func (d *DefaultHttpClient) Patch(url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
func (*DefaultHttpClient) Post ¶
func (d *DefaultHttpClient) Post(url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
func (*DefaultHttpClient) Put ¶
func (d *DefaultHttpClient) Put(url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
func (*DefaultHttpClient) Request ¶
func (d *DefaultHttpClient) Request(method string, url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
type HttpClient ¶
type HttpClient interface {
Get(url string, result interface{}, options ...RequestOption) (*HttpResponse, error)
Post(url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
Put(url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
Patch(url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
Delete(url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
Request(method string, url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
}
func NewDefaultHttpClient ¶
func NewDefaultHttpClient(base *http.Client) HttpClient
type HttpClientProperties ¶
type HttpClientProperties struct {
// Timeout specifies a time limit for requests made by this client.
// The timeout includes connection time, any redirects, and reading the response body.
// A Timeout of zero means no timeout.
Timeout time.Duration `default:"60s"`
// MaxIdleConns is the connection pool size,
// and this is the maximum connection that can be open;
// its default value is 100 connections, zero means no limit.
MaxIdleConns int `default:"100"`
// MaxIdleConnsPerHost is the number of connection can be allowed to open per host basic.
// If zero, http.Transport DefaultMaxIdleConnsPerHost is used.
MaxIdleConnsPerHost int `default:"100"`
// MaxConnsPerHost optionally limits the total number of
// connections per host, including connections in the dialing,
// active, and idle states. On limit violation, dials will block.
// Zero means no limit.
MaxConnsPerHost int `default:"100"`
// Proxy specify proxy url and urls will apply proxy and
// the requests with these urls will be requested under proxy
Proxy ProxyProperties
}
func NewHttpClientProperties ¶
func NewHttpClientProperties(loader config.Loader) (*HttpClientProperties, error)
func (HttpClientProperties) Prefix ¶
func (h HttpClientProperties) Prefix() string
type HttpResponse ¶
type HttpSeries ¶
type HttpSeries int
const ( SeriesInformational HttpSeries = 1 SeriesSuccessful HttpSeries = 2 SeriesRedirection HttpSeries = 3 SeriesClientError HttpSeries = 4 SeriesServerError HttpSeries = 5 )
func NewHttpSeries ¶
func NewHttpSeries(statusCode int) HttpSeries
func (HttpSeries) Is ¶
func (h HttpSeries) Is(series HttpSeries) bool
func (HttpSeries) IsError ¶
func (h HttpSeries) IsError() bool
type ProxyProperties ¶
type ProxyProperties struct {
// Url is proxy url. Example: http://localhost:8080
Url string
// AppliedUris is the list of URIs, which will be requested under above proxy
// Example:
// https://example.com/path/
// All URL starts with https://example.com/path/ will be request under proxy
AppliedUris []string
}
type RequestOption ¶
func WithBasicAuth ¶
func WithBasicAuth(username string, password string) RequestOption
func WithContentLength ¶
func WithContentLength(length int) RequestOption
func WithContentType ¶
func WithContentType(contentType string) RequestOption
func WithHeader ¶
func WithHeader(key string, value string) RequestOption
type RequestReader ¶
type TraceableHttpClient ¶
type TraceableHttpClient struct {
// contains filtered or unexported fields
}
func (*TraceableHttpClient) Delete ¶
func (t *TraceableHttpClient) Delete(ctx context.Context, url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
func (*TraceableHttpClient) Get ¶
func (t *TraceableHttpClient) Get(ctx context.Context, url string, result interface{}, options ...RequestOption) (*HttpResponse, error)
func (*TraceableHttpClient) Patch ¶
func (t *TraceableHttpClient) Patch(ctx context.Context, url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
func (*TraceableHttpClient) Post ¶
func (t *TraceableHttpClient) Post(ctx context.Context, url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
func (*TraceableHttpClient) Put ¶
func (t *TraceableHttpClient) Put(ctx context.Context, url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
func (*TraceableHttpClient) Request ¶
func (t *TraceableHttpClient) Request(ctx context.Context, method string, url string, body interface{}, result interface{}, options ...RequestOption) (*HttpResponse, error)
Click to show internal directories.
Click to hide internal directories.