webserver

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Address

func Address(addr string) func(*Server)

Address is a functional option to set the address of the webserver

func ErrorCh

func ErrorCh(ch chan struct{}) func(*Server)

ErrorCh is a functional option which provides channel to the webserver which will be closed if an unrecoverable error happens

func Mf823Address

func Mf823Address(a string) func(*Server)

Mf823Address is a functional option which sets the ip address of a a ZTE MF823 4G USB modem

func Mf823Parameters

func Mf823Parameters(p []string) func(*Server)

Mf823Parameters is a functional option which sets the parameters which will be retrieved from a ZTE MF823 4G USB modem

func Microtik

func Microtik(m *microtik.Microtik) func(*Server)

Microtik is a functional option which sets an instance of a Microtik router

func PingAddress

func PingAddress(addresses []string) func(*Server)

PingAddress sets the hosts to be pinged

func PingEnabled

func PingEnabled(enabled bool) func(*Server)

PingEnabled enables the background job to ping the provided hosts in the defined interval. Otherwise the hosts will only be pinged on the execution of the corresponing http call

func PingInterval

func PingInterval(interval time.Duration) func(*Server)

PingInterval sets the interval in which the provided hosts will be pinged

func PingSamples

func PingSamples(samples int) func(*Server)

PingSamples sets the amount of pings sent to each host (for averaging)

func PingTimeout

func PingTimeout(timeout time.Duration) func(*Server)

PingTimeout sets the timeout for each ping query cycle

func Port

func Port(port int) func(*Server)

Port is a functional option to set the port on which the webserver will listen

func Route

func Route(routeName string) func(*Server)

Route authorizes the webserver to access a microtik route

func Service

func Service(serviceName string) func(*Server)

Service authorizes the webserver to control a systemd service. Services can either be specified with or without the extension ".service"

Types

type Option

type Option func(*Server)

Option is the type used for functional options

type Server

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

func New

func New(opts ...Option) *Server

New returns an instance of a Server configured according to the provided options.

func (*Server) Serve

func (s *Server) Serve()

Serve starts a HTTP Server on a given network adapter / port and sets a HTTP handler. Since this function contains an endless loop, it should be executed in a go routine. If the listener can not be initialized, it will close the errorCh channel.

Jump to

Keyboard shortcuts

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