Back to godoc.org
egt.run/lanhttp

Package lanhttp

v0.0.0-...-967092d
Latest Go to latest

The highest tagged major version is .

Published: Apr 7, 2020 | License: ISC | Module: egt.run/lanhttp

Index

type Client

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

func DefaultClient

func DefaultClient(timeout time.Duration) *Client

func NewClient

func NewClient(client HTTPClient) *Client

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

func (*Client) ResolveHost

func (c *Client) ResolveHost(uri *url.URL) *url.URL

ResolveHost from a URL to a specific IP if internal, otherwise return the URL unmodified.

func (*Client) Routes

func (c *Client) Routes() Routes

Routes returns a copy of all live backend IPs.

func (*Client) StartUpdating

func (c *Client) StartUpdating(urls []string, every time.Duration)

StartUpdating live backends with an initial, synchronous update before continuing. Try all URLs simultaneously and use results from the first reply. Note that even when this fails, we still allow the code to continue... Just don't expect internal IPs to route until the servers come online.

func (*Client) StopUpdating

func (c *Client) StopUpdating()

func (*Client) WithLogger

func (c *Client) WithLogger(lg Logger) *Client

WithLogger replaces the logger of a client in a threadsafe way. This can be used for instance to load up the internal LAN clients immediately, then update the logger with new settings later in the program, e.g. after environment variables are loaded and you try to connect to internal services.

func (*Client) WithRoutes

func (c *Client) WithRoutes(routes Routes) *Client

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

type Logger

type Logger interface{ Printf(string, ...interface{}) }

Logger is the public logging interface. We wrap this with our own logger to provide some more control.

type Routes

type Routes map[string][]string

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier