http

package
v3.59.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OptSetLogger

func OptSetLogger(log log.Modular) func(*Client)

OptSetLogger sets the logger to use.

func OptSetManager

func OptSetManager(mgr types.Manager) func(*Client)

OptSetManager sets the manager to use.

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

func OptSetStats(stats metrics.Type) func(*Client)

OptSetStats sets the metrics aggregator to use.

func UnexpectedErr added in v3.57.0

func UnexpectedErr(res *http.Response) error

UnexpectedErr get error body

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 NewClient

func NewClient(conf client.Config, opts ...func(*Client)) (*Client, error)

NewClient creates a new http client that sends and receives Benthos messages.

func (*Client) Close

func (h *Client) Close(ctx context.Context) error

Close the client.

func (*Client) CreateRequest

func (h *Client) CreateRequest(sendMsg, refMsg types.Message) (req *http.Request, err error)

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

func (h *Client) ParseResponse(res *http.Response) (resMsg types.Message, err error)

ParseResponse attempts to parse an HTTP response into a 2D slice of bytes.

func (*Client) Send

func (h *Client) Send(ctx context.Context, sendMsg, refMsg types.Message) (types.Message, error)

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 types.Message) (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.

Jump to

Keyboard shortcuts

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