kbhttp

package
v3.1.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2019 License: BSD-3-Clause, BSD-3-Clause Imports: 6 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPinnedPortInUse = errors.New("unable to bind to pinned port")

Functions

This section is empty.

Types

type ListenerSource

type ListenerSource interface {
	GetListener() (net.Listener, string, error)
}

ListenerSource represents where an HTTP server should listen.

type PortRangeListenerSource

type PortRangeListenerSource struct {
	sync.Mutex
	// contains filtered or unexported fields
}

PortRangeListenerSource means listen on the given range.

func NewFixedPortListenerSource

func NewFixedPortListenerSource(port int) *PortRangeListenerSource

NewFixedPortListenerSource creates a new PortListenerSource listening on the given port.

func NewPortRangeListenerSource

func NewPortRangeListenerSource(low, high int) *PortRangeListenerSource

NewPortRangeListenerSource creates a new PortListenerSource listening on low to high (inclusive).

func (*PortRangeListenerSource) GetListener

func (p *PortRangeListenerSource) GetListener() (listener net.Listener, address string, err error)

GetListener implements ListenerSource.

type RandomPortListenerSource

type RandomPortListenerSource struct{}

RandomPortListenerSource means listen on a random port.

func NewRandomPortListenerSource

func NewRandomPortListenerSource() *RandomPortListenerSource

NewRandomPortListenerSource creates a new RandomPortListenerSource.

func (RandomPortListenerSource) GetListener

func (r RandomPortListenerSource) GetListener() (net.Listener, string, error)

GetListener implements ListenerSource.

type Srv

type Srv struct {
	sync.Mutex
	*http.ServeMux
	// contains filtered or unexported fields
}

Srv starts a simple HTTP server with a parameter for a module to provide a listener source

func NewSrv

func NewSrv(log logger.Logger, listenerSource ListenerSource) *Srv

NewSrv creates a new HTTP server with the given listener source.

func (*Srv) Active

func (h *Srv) Active() bool

Active returns true if the server is active.

func (*Srv) Addr

func (h *Srv) Addr() (string, error)

Addr returns the server's address, if it's running.

func (*Srv) Start

func (h *Srv) Start() (err error)

Start starts listening on the server's listener source.

func (*Srv) Stop

func (h *Srv) Stop()

Stop stops listening on the server's listener source.

Jump to

Keyboard shortcuts

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