http

package
v0.0.0-...-d945414 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Client

func Client() *http.Client

Client returns a new, wrapped http.Client.

func CopyDeadline

func CopyDeadline(ctx context.Context, h http.Header) (context.Context, context.CancelFunc)

CopyDeadline searches for the deadline in the headers and returns an updated context with a cancellation function. If the headers do not include the deadline value, the context is returned unchanged and the cancellation function will be nil.

func Extract

func Extract(ctx context.Context, h http.Header) context.Context

Extract extracts the values from the headers (or trailers) and returns a new context with the values found. This method will never set a deadline on the context.

func ExtractWithDeadline

func ExtractWithDeadline(ctx context.Context, h http.Header) (context.Context, context.CancelFunc)

ExtractWithDeadline works as Extract, but will set a deadline if one is found in the headers. In that case (only), the cancellation function will be nil.

func WrapClient

func WrapClient(c *http.Client) *http.Client

WrapClient wraps a standard http.Client.

func WrapHandler

func WrapHandler(h http.Handler) http.Handler

WrapHandler wraps an http.Handler, adding configured values to the incoming context. Sets a deadline (and handles its cancellation) when one is found. Does not process outgoing response headers.

func WrapHandlerFunc

func WrapHandlerFunc(h http.HandlerFunc) http.HandlerFunc

WrapHandlerFunc wraps an http.HandlerFunc, adding configured values to the incoming context. Sets a deadline (and handles its cancellation) when one is found. Does not process outgoing response headers.

Types

type ContextRoundTripper

type ContextRoundTripper struct {
	// contains filtered or unexported fields
}

A ContextRoundTripper propagates the configured context values in an outgoing HTTP request. It does not handle returned response headers.

func (ContextRoundTripper) RoundTrip

func (c ContextRoundTripper) RoundTrip(r *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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