Documentation ¶
Overview ¶
Package http is used for building observable HTTP servers and clients that automatically report logs, metrics, and traces.
Index ¶
- type Client
- func (c *Client) CloseIdleConnections()
- func (c *Client) Do(req *http.Request) (*http.Response, error)
- func (c *Client) Get(url string) (resp *http.Response, err error)
- func (c *Client) Head(url string) (resp *http.Response, err error)
- func (c *Client) Post(url, contentType string, body io.Reader) (resp *http.Response, err error)
- func (c *Client) PostForm(url string, data url.Values) (resp *http.Response, err error)
- type Middleware
- type Options
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a drop-in replacement for the standard http.Client. It is an observable http client with logging, metrics, and tracing.
func (*Client) CloseIdleConnections ¶
func (c *Client) CloseIdleConnections()
CloseIdleConnections is the observable counterpart of standard http Client.CloseIdleConnections.
func (*Client) Get ¶
Get is the observable counterpart of standard http Client.Get. Using this method, request context (UUID and trace) will be auto-generated. If you have a context for the request, consider using the Do method.
func (*Client) Head ¶
Head is the observable counterpart of standard http Client.Head. Using this method, request context (UUID and trace) will be auto-generated. If you have a context for the request, consider using the Do method.
func (*Client) Post ¶
Post is the observable counterpart of standard http Client.Post. Using this method, request context (UUID and trace) will be auto-generated. If you have a context for the request, consider using the Do method.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware creates observable http handlers with logging, metrics, and tracing.
func NewMiddleware ¶
func NewMiddleware(probe telemetry.Probe, opts Options) *Middleware
NewMiddleware creates a new observable http middleware.
func (*Middleware) Wrap ¶
func (m *Middleware) Wrap(next http.HandlerFunc) http.HandlerFunc
Wrap wraps an existing http handler function and returns a new observable handler function. This can be used for making http handlers observable via logging, metrics, tracing, etc. It also observes and recovers panics that happened inside the inner http handler.