internal

package
v0.0.0-...-82d8ad3 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProxy

func NewProxy(target *url.URL) *httputil.ReverseProxy

NewProxy configures a reverse proxy handler for a single upstream target.

Types

type Server

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

Server wrapper http.Server and net.Listener to make access to certain internal fields more easily accessible.

func NewServer

func NewServer(target *url.URL) *Server

NewServer creates an http server with a reverse proxy handler. We split the live server and proxy handler for testability.

func (*Server) Listen

func (s *Server) Listen(address string) error

Listen creates a listener on the given address. It stores the listener for later calls to Serve, and to allow programmatic retrieval of the listening address for cases where it is randomized (e.g. ':0').

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(address string) error

ListenAndServe is a convenience method for Listen() and Serve(). Listen and Serve primarily make sense to call separately in testing, so the listener can allocate a port before we spin of Serve() in a goroutine. In production, you'd likely only need listen and server, unless you want programmatic access to the listener address (e.g. multiple servers).

func (*Server) Serve

func (s *Server) Serve() error

Serve starts the http server with the existing listener.

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown cleanly shuts down the server. It's primarily used for testing.

func (*Server) URL

func (s *Server) URL() string

URL returns the server listening URL when a random port is used. This allows programmatic randomization of ports during testing.

Jump to

Keyboard shortcuts

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