Documentation ¶
Index ¶
- type HttpClient
- func (cl *HttpClient) Do(req *http.Request) (*http.Response, error)
- func (cl *HttpClient) Get(url string) (*http.Response, error)
- func (cl *HttpClient) Head(url string) (*http.Response, error)
- func (cl *HttpClient) Post(url, contentType string, body io.Reader) (*http.Response, error)
- func (cl *HttpClient) PostForm(url string, data url.Values) (*http.Response, error)
- func (cl *HttpClient) SetCtxHttpClient(ctx context.Context)
- type ReadCloser
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HttpClient ¶
HttpClient used to mock http.Client methods in order to store or retrieve outputs from request's context.
func NewHttpClient ¶
func NewHttpClient(client *http.Client) *HttpClient
NewHttpClient is used to embed the http.Client pointer in order to mock its methods. The purpose is to capture or replay its method's outputs according to "KEPLOY_SDK_MODE". It returns nil if client parameter is nil.
Note: Always call SetCtxHttpClient method of *integrations.HttpClient before using http-client's method. This should be done so that request's context can be modified for storing or retrieving outputs of http methods.
func (*HttpClient) Do ¶
Do is used to override http.Client's Do method. More about this net/http method: https://pkg.go.dev/net/http#Client.Do.
func (*HttpClient) Get ¶
func (cl *HttpClient) Get(url string) (*http.Response, error)
Get mocks the http.Client.Get method of net/http package. More about this net/http method: https://pkg.go.dev/net/http#Client.Get.
func (*HttpClient) Head ¶
func (cl *HttpClient) Head(url string) (*http.Response, error)
Head mocks http.Client.Head method. More about this net/http method: https://pkg.go.dev/net/http#Client.Head.
func (*HttpClient) Post ¶
Post mocks the http.Client.Post method. More about this net/http method: https://pkg.go.dev/net/http#Client.Post.
func (*HttpClient) PostForm ¶
PostForm Method mocks net/http Client's method. About mocked method: https://pkg.go.dev/net/http#Client.PostForm.
func (*HttpClient) SetCtxHttpClient ¶
func (cl *HttpClient) SetCtxHttpClient(ctx context.Context)
SetCtxHttpClient is used to set integrations.HttpClient.ctx to http.Request.Context(). It should be called before calling any http.Client method so that, their outputs can be stored or retrieved from http.Request.Context() according to "KEPLOY_SDK_MODE".
ctx parameter should be the context of http.Request.
type ReadCloser ¶
type ReadCloser struct { *bytes.Reader Body io.ReadCloser }
ReadCloser is used so that gob could encode-decode http.Response.
func (ReadCloser) Close ¶
func (rc ReadCloser) Close() error
func (*ReadCloser) MarshalBinary ¶
func (rc *ReadCloser) MarshalBinary() ([]byte, error)
func (*ReadCloser) UnmarshalBinary ¶
func (rc *ReadCloser) UnmarshalBinary(b []byte) error