Documentation ¶
Index ¶
- Variables
- type Client
- func (c *Client) CloseIdleConnections(ctx context.Context)
- func (c *Client) Do(ctx context.Context, req *http.Request) (*http.Response, error)
- func (c *Client) Get(ctx context.Context, addr string) (resp *http.Response, err error)
- func (c *Client) Head(ctx context.Context, addr string) (resp *http.Response, err error)
- func (c *Client) Post(ctx context.Context, addr, contentType string, body io.Reader) (resp *http.Response, err error)
- func (c *Client) PostForm(ctx context.Context, addr string, data url.Values) (resp *http.Response, err error)
- type ClientOptions
- type MonitorProxy
- type MonitorProxyOption
- type MonitorProxyOptions
- type Option
- type RespFunc
- type StubsProxy
- type StubsProxyOption
- type StubsProxyOptions
Constants ¶
This section is empty.
Variables ¶
View Source
var GlobalStub func(*http.Request) *http.Response
GlobalStub is test double and it is used when we cannot or don’t want to involve real server. Instead of the real server, we introduced a stub and defined what data should be returned. Example:
func(request *http.Request) *http.Response { resp := &http.Response{} if request.URL.String() == "127.0.0.1" { resp.StatusCode = http.StatusOK resp.Body = ioutil.NopCloser(bytes.NewReader([]byte{})) } return resp }
Functions ¶
This section is empty.
Types ¶
type Client ¶ added in v0.0.5
type Client struct {
// contains filtered or unexported fields
}
func (*Client) CloseIdleConnections ¶ added in v0.0.5
type ClientOptions ¶
type ClientOptions struct{}
func (ClientOptions) WithLogger ¶
func (ClientOptions) WithLogger(logger log.Logger) Option
func (ClientOptions) WithProxy ¶
func (ClientOptions) WithProxy(proxys ...func() interface{}) Option
func (ClientOptions) WithTimeOut ¶
func (ClientOptions) WithTimeOut(timeout time.Duration) Option
type MonitorProxy ¶ added in v0.0.9
type MonitorProxy struct {
// contains filtered or unexported fields
}
MonitorProxy wraps a RoundTripper.
func NewMonitorProxy ¶
func NewMonitorProxy(options ...MonitorProxyOption) *MonitorProxy
func (*MonitorProxy) NextProxy ¶ added in v0.0.9
func (mp *MonitorProxy) NextProxy(tripper interface{})
func (*MonitorProxy) ProxyName ¶ added in v0.0.9
func (mp *MonitorProxy) ProxyName() string
type MonitorProxyOption ¶
type MonitorProxyOption func(c *MonitorProxy)
type MonitorProxyOptions ¶
type MonitorProxyOptions struct{}
func (MonitorProxyOptions) WithConf ¶
func (MonitorProxyOptions) WithConf(conf config.Config) MonitorProxyOption
func (MonitorProxyOptions) WithLogger ¶
func (MonitorProxyOptions) WithLogger(logger log.Logger) MonitorProxyOption
func (MonitorProxyOptions) WithTracer ¶
func (MonitorProxyOptions) WithTracer(tracer opentracing2.Tracer) MonitorProxyOption
Use nethttp.Tracer.
type StubsProxy ¶ added in v0.1.2
type StubsProxy struct {
// contains filtered or unexported fields
}
func NewStubsProxy ¶
func NewStubsProxy(options ...StubsProxyOption) *StubsProxy
func (*StubsProxy) NextProxy ¶ added in v0.1.2
func (sp *StubsProxy) NextProxy(tripper interface{})
func (*StubsProxy) ProxyName ¶ added in v0.1.2
func (sp *StubsProxy) ProxyName() string
type StubsProxyOption ¶
type StubsProxyOption func(c *StubsProxy)
type StubsProxyOptions ¶
type StubsProxyOptions struct{}
func (StubsProxyOptions) WithLogger ¶
func (StubsProxyOptions) WithLogger(logger log.Logger) StubsProxyOption
func (StubsProxyOptions) WithName ¶
func (StubsProxyOptions) WithName(name string) StubsProxyOption
func (StubsProxyOptions) WithRespFunc ¶
func (StubsProxyOptions) WithRespFunc(respFunc RespFunc) StubsProxyOption
Click to show internal directories.
Click to hide internal directories.