Documentation ¶
Overview ¶
Package http provides HTTP client and server implementations.
Package http provides HTTP client and server implementations.
Package http provides HTTP client and server implementations.
Package http provides HTTP client and server implementations.
Index ¶
- Constants
- Variables
- func GetWithContext(ctx context.Context, url string) (resp *http.Response, err error)
- type Client
- type Handler
- type HandlerFunc
- type Option
- type OptionFunc
- type Request
- type Response
- func Get(url string) (resp *Response, err error)
- func Head(url string) (resp *Response, err error)
- func HeadWithContext(ctx context.Context, url string) (resp *Response, err error)
- func Post(url, contentType string, body io.Reader) (resp *Response, err error)
- func PostForm(url string, data url.Values) (resp *Response, err error)
- func PostFormWithContext(ctx context.Context, url string, data url.Values) (resp *Response, err error)
- func PostWithContext(ctx context.Context, url, contentType string, body io.Reader) (resp *Response, err error)
- type RoundTripper
- type SpanNameFormatter
- type Transport
Constants ¶
const ( MethodGet = http.MethodGet MethodHead = http.MethodHead MethodPost = http.MethodPost MethodPut = http.MethodPut MethodPatch = http.MethodPatch MethodDelete = http.MethodDelete MethodConnect = http.MethodConnect MethodOptions = http.MethodOptions MethodTrace = http.MethodTrace )
Common HTTP methods.
Variables ¶
var DefaultClient = mustClient(NewClient(http.DefaultClient))
DefaultClient is the default Client and is used by Get, Head, and Post.
var DefaultTransport = http.DefaultTransport
DefaultTransport is the default implementation of Transport and is used by DefaultClient.
Functions ¶
Types ¶
type Client ¶
A Client is an HTTP client. Its zero value (DefaultClient) is a usable client that uses DefaultTransport.
type HandlerFunc ¶
type HandlerFunc = http.HandlerFunc
The HandlerFunc type is an adapter to allow the use of ordinary functions as HTTP handlers. If f is a function with the appropriate signature, HandlerFunc(f) is a Handler that calls f.
type Option ¶
type Option interface {
Apply(*config)
}
Option applies a configuration to the given config.
func WithMeterProvider ¶
func WithMeterProvider(mp metric.MeterProvider) Option
WithMeterProvider specifies a meter provider to use for creating a meter. If none is specified, the global provider is used.
func WithOperationName ¶
WithOperationName specifies a operation name. If none is specified, the default operation name is used
func WithPropagators ¶
func WithPropagators(ps propagation.TextMapPropagator) Option
WithPropagators specifies a propagators. If none is specified, the global propagator is used.
func WithSpanNameFormatter ¶
func WithSpanNameFormatter(f SpanNameFormatter) Option
WithSpanNameFormatter specifies a formatter to used to format span names. If none is specified, the default SpanNameFormatter is used
func WithTracerProvider ¶
func WithTracerProvider(tp trace.TracerProvider) Option
WithTracerProvider specifies a tracer provider to use for creating a tracer. If none is specified, the global provider is used.
type OptionFunc ¶
type OptionFunc func(c *config)
OptionFunc provides a convenience wrapper for simple Options that can be represented as functions.
func (OptionFunc) Apply ¶
func (o OptionFunc) Apply(c *config)
Apply will apply the option to the config.
type Request ¶
A Request represents an HTTP request received by a server or to be sent by a client.
func NewRequest ¶
NewRequest wraps NewRequestWithContext using the background context.
type Response ¶
Response represents the response from an HTTP request.
func HeadWithContext ¶
HeadWithContext is a convenient replacement for http.Head that adds a span around the request.
func PostForm ¶
PostForm issues a POST to the specified URL, with data's keys and values URL-encoded as the request body.
type RoundTripper ¶
type RoundTripper = http.RoundTripper
RoundTripper is an interface representing the ability to execute a single HTTP transaction, obtaining the Response for a given Request.
func NewOTelTransport ¶
func NewOTelTransport(rt RoundTripper, opts ...Option) (RoundTripper, error)
NewOTelTransport wraps the provided RoundTripper with one that starts a span and injects the span context into the outbound request headers. If none is specified, the DefaultTransport is used.
type SpanNameFormatter ¶
SpanNameFormatter creates a custom span name from the operation and db object.