godock: github.com/sqp/godock/libs/net/websrv Index | Files

package websrv

import "github.com/sqp/godock/libs/net/websrv"

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

Index

Package Files

websrv.go

Constants

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

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
)

func Init Uses

func Init(log cdtype.Logger)

Init creates the default Service with a logger for monitoring.

type Srv Uses

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

Srv defines a web service handling subservices.

func NewSrv Uses

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 Uses

func (s *Srv) IsMonitored() bool

IsMonitored returns whether monitoring pages are active or not.

func (*Srv) Register Uses

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 Uses

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 Uses

func (s *Srv) SetMonitored(setActive bool)

SetMonitored sets if monitoring pages are active or not.

func (*Srv) Start Uses

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

Start starts the registered service matching the given prefix key.

func (*Srv) Stop Uses

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

Stop stops the registered service matching the given prefix key.

func (*Srv) URL Uses

func (s *Srv) URL() string

URL returns the service location: host:port

func (*Srv) Unregister Uses

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

Unregister unregisters the service matching the given prefix key.

Package websrv imports 9 packages (graph) and is imported by 3 packages. Updated 2017-10-04. Refresh now. Tools for package owners.