websrv

package
v0.0.0-...-0caaa62 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2017 License: GPL-3.0-or-later Imports: 9 Imported by: 0

Documentation

Overview

Package websrv manages the default optional web service for the program with variable subservices.

Index

Constants

View Source
const (
	// PathPprof is the registered url for the monitoring pprof service.
	PathPprof = "debug/pprof"

	// PathCharts is the registered url for the monitoring charts service.
	PathCharts = "debug/charts"
)

Variables

View Source
var (
	// DefaultHost is the default hostname used for the web service.
	DefaultHost = "localhost"

	// DefaultPort is the default port used for the web service.
	DefaultPort = 15610

	// Service manages the default web service for the program.
	Service *Srv
)

Functions

func Init

func Init(log cdtype.Logger)

Init creates the default Service with a logger for monitoring.

Types

type Srv

type Srv struct {
	Host string // Where to
	Port int    // Listen.
	// contains filtered or unexported fields
}

Srv defines a web service handling subservices.

func NewSrv

func NewSrv(host string, port int, log cdtype.Logger) *Srv

NewSrv creates a new web service managing multiple You better use the already created Service var.

func (*Srv) IsMonitored

func (s *Srv) IsMonitored() bool

IsMonitored returns whether monitoring pages are active or not.

func (*Srv) Register

func (s *Srv) Register(key string, call http.HandlerFunc, log cdtype.Logger) error

Register registers the service matching the given prefix key.

func (*Srv) ServeHTTP

func (s *Srv) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP forwards the web call to the services matching the url prefix.

func (*Srv) SetMonitored

func (s *Srv) SetMonitored(setActive bool)

SetMonitored sets if monitoring pages are active or not.

func (*Srv) Start

func (s *Srv) Start(key string) error

Start starts the registered service matching the given prefix key.

func (*Srv) Stop

func (s *Srv) Stop(key string) error

Stop stops the registered service matching the given prefix key.

func (*Srv) URL

func (s *Srv) URL() string

URL returns the service location: host:port

func (*Srv) Unregister

func (s *Srv) Unregister(key string) error

Unregister unregisters the service matching the given prefix key.

Jump to

Keyboard shortcuts

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