Documentation ¶
Index ¶
- func OptSetLogger(log log.Modular) func(*Client)
- func OptSetManager(mgr bundle.NewManagement) func(*Client)
- func OptSetMultiPart(multipart []MultipartExpressions) func(*Client)
- func OptSetRoundTripper(rt http.RoundTripper) func(*Client)
- func OptSetStats(stats metrics.Type) func(*Client)
- func UnexpectedErr(res *http.Response) error
- type Client
- func (h *Client) Close(ctx context.Context) error
- func (h *Client) CreateRequest(sendMsg, refMsg message.Batch) (req *http.Request, err error)
- func (h *Client) ParseResponse(res *http.Response) (resMsg message.Batch, err error)
- func (h *Client) Send(ctx context.Context, sendMsg, refMsg message.Batch) (message.Batch, error)
- func (h *Client) SendToResponse(ctx context.Context, sendMsg, refMsg message.Batch) (res *http.Response, err error)
- type MultipartExpressions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OptSetLogger ¶
OptSetLogger sets the logger to use.
func OptSetManager ¶
func OptSetManager(mgr bundle.NewManagement) func(*Client)
OptSetManager sets the manager to use.
func OptSetMultiPart ¶
func OptSetMultiPart(multipart []MultipartExpressions) func(*Client)
OptSetMultiPart sets the multipart to request.
func OptSetRoundTripper ¶
func OptSetRoundTripper(rt http.RoundTripper) func(*Client)
OptSetRoundTripper sets the *client.Transport to use for HTTP requests. NOTE: This setting will override any configured TLS options.
func OptSetStats ¶
OptSetStats sets the metrics aggregator to use.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a component able to send and receive Benthos messages over HTTP.
func (*Client) CreateRequest ¶
CreateRequest forms an *http.Request from a message to be sent as the body, and also a message used to form headers (they can be the same).
func (*Client) ParseResponse ¶
ParseResponse attempts to parse an HTTP response into a 2D slice of bytes.
func (*Client) Send ¶
Send creates an HTTP request from the client config, a provided message to be sent as the body of the request, and a reference message used to establish interpolated fields for the request (which can be the same as the message used for the body).
If the request is successful then the response is parsed into a message, including headers added as metadata (when configured to do so).
func (*Client) SendToResponse ¶
func (h *Client) SendToResponse(ctx context.Context, sendMsg, refMsg message.Batch) (res *http.Response, err error)
SendToResponse attempts to create an HTTP request from a provided message, performs it, and then returns the *http.Response, allowing the raw response to be consumed.
type MultipartExpressions ¶
type MultipartExpressions struct { ContentDisposition *field.Expression ContentType *field.Expression Body *field.Expression }
MultipartExpressions represents three dynamic expressions that define a multipart message part in an HTTP request. Specifying one or more of these can be used as a way of creating HTTP requests that overrides the default behaviour.