webapp

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Static

func Static(w web.ResponseWriter, req *web.Request, next web.NextMiddlewareFunc)

Types

type AddLightRequest

type AddLightRequest struct {
	Name string
}

type ByName

type ByName []Light

func (ByName) Len

func (a ByName) Len() int

func (ByName) Less

func (a ByName) Less(i, j int) bool

func (ByName) Swap

func (a ByName) Swap(i, j int)

type Light

type Light struct {
	GroupID    string `json:"group_id"`
	LightID    string `json:"light_id"`
	Name       string `json:"name"`
	On         bool   `json:"on"`
	Brightness int32  `json:"brightness"`
}

type LightsResponse

type LightsResponse struct {
	Groups []string `json:"groups"`
	Lights []Light  `json:"lights"`
}

type WebApp

type WebApp struct {
	DB   *devicedb.DeviceDB
	Nats *natsserver.NatsServer
	// contains filtered or unexported fields
}

func New

func New(db *devicedb.DeviceDB, nats *natsserver.NatsServer, logger *log.Logger, tlsHostName string) *WebApp

func (*WebApp) Run

func (w *WebApp) Run(addr string, ctx context.Context)

type WebContext

type WebContext struct {
	App *WebApp
}

func (*WebContext) AddLight

func (w *WebContext) AddLight(rw web.ResponseWriter, req *web.Request)

func (*WebContext) ChangeState

func (w *WebContext) ChangeState(rw web.ResponseWriter, req *web.Request)

func (*WebContext) DeleteLight

func (w *WebContext) DeleteLight(rw web.ResponseWriter, req *web.Request)

func (*WebContext) Lights

func (w *WebContext) Lights(rw web.ResponseWriter, req *web.Request)

func (*WebContext) Messages

func (w *WebContext) Messages(rw web.ResponseWriter, req *web.Request)

func (*WebContext) OnConnected

func (w *WebContext) OnConnected(ws *websocket.Conn)

type WsMessage

type WsMessage struct {
	MsgType string      `json:"msg_type"`
	Data    interface{} `json:"data"`
}

Jump to

Keyboard shortcuts

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