kbhttp

package
v2.6.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: BSD-3-Clause, BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

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