socket

package
v0.0.0-...-8223eb1 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHTTPClient

func NewHTTPClient(socketPath, consulHost string, extras map[string]string) *http.Client

NewHTTPClient returns an *http.Client which will send all HTTP requests to the unix socket at socketPath, and will encode the proper request metadata to make all requests route to Consul

func NewTransport

func NewTransport(socketPath, consulHost string, extras map[string]string) http.RoundTripper

func Path

func Path(pathEnvVar string) (string, error)

Types

type UnixSocketTransport

type UnixSocketTransport struct {
	// Transport does the actual work of sending the HTTP requests after
	// UnixSocketTransport rewrites certain request metadata
	*http.Transport

	// The name of Consul added as the request host header
	ConsulHost string
}

UnixSocketTransport provides an http.RoundTripper that wraps around another RoundTripper, adding needed metadata to each request

func (UnixSocketTransport) RoundTrip

func (t UnixSocketTransport) RoundTrip(r *http.Request) (*http.Response, error)

RoundTrip implements the http.RoundTripper interface. It modifies the HTTP request to inject the necessary request metadata for the request to be route the request to the right place. The modified HTTP request is then passed to the wrapped *http.Transport (also an implementation of RoundTripper).

Jump to

Keyboard shortcuts

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