webserver

package
v0.0.0-...-cb9b391 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2020 License: MPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MessageTypeDefault   = "message"
	MessageTypeHeartbeat = "heartbeat"
	MessageTypeService   = "service"
)

Variables

This section is empty.

Functions

func GetVisitorAddress

func GetVisitorAddress(r *http.Request) string

func InjectHeartbeat

func InjectHeartbeat(r *http.Request, m Messenger)

func Mux

func Mux(webDir string, broker *eventbroker.Broker, counter *metrics.Counter) *http.ServeMux

Types

type IndexHandler

type IndexHandler struct{}

func (IndexHandler) ServeHTTP

func (i IndexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type MessageHandler

type MessageHandler struct {
	Broker *eventbroker.Broker
}

func (MessageHandler) ServeHTTP

func (m MessageHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Messenger

type Messenger interface {
	Inject(msgType string, msgValue string)
}

type Metrics

type Metrics struct {
	Status           string `json:"status"` // PLACEHOLDER
	OpenConnections  int    `json:"open_connections"`
	Visitors         int    `json:"visitors_total"`
	VisitorsUnique   int    `json:"visitors_unique"`
	Messages         int    `json:"messages_total"`
	MessagesLastHour int    `json:"messages_last_hour"`
}

type MetricsHandler

type MetricsHandler struct {
	Counter *metrics.Counter
}

func (*MetricsHandler) ServeHTTP

func (m *MetricsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type NotificationHandler

type NotificationHandler struct {
	Broker  *eventbroker.Broker
	Counter *metrics.Counter
}

func (*NotificationHandler) ServeHTTP

func (n *NotificationHandler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Payload

type Payload struct {
	Message string `json:"message"`
}

func (*Payload) Escaped

func (p *Payload) Escaped() string

func (*Payload) IsValid

func (p *Payload) IsValid() bool

Jump to

Keyboard shortcuts

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