api

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: May 8, 2020 License: Apache-2.0 Imports: 17 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAppHandler

func NewAppHandler(db *db.Db, influx *db.Influx, getAsset func(string) []byte,
	filesystem http.FileSystem, debug bool) http.Handler

NewAppHandler returns a new application (root) http handler

func NewDevicesHandler

func NewDevicesHandler(db *db.Db, influx *db.Influx) http.Handler

NewDevicesHandler returns a new device handler

func NewGetCmd

func NewGetCmd(portalURL, deviceID string, timeout time.Duration, debug bool) func() (data.DeviceCmd, error)

NewGetCmd returns a function that can be used to get device commands from the portal.

func NewIndexHandler

func NewIndexHandler(getAsset func(string) []byte) http.Handler

NewIndexHandler returns a new Index handler

func NewSendSamples

func NewSendSamples(portalURL, deviceID string, timeout time.Duration, debug bool) func([]data.Sample) error

NewSendSamples returns a function that can be used to send samples to a SimpleIoT portal instance

func NewSetVersion

func NewSetVersion(portalURL, deviceID string, timeout time.Duration, debug bool) func(ver data.DeviceVersion) error

NewSetVersion sets the device version in the portal

func NewV1Handler

func NewV1Handler(db *db.Db, influx *db.Influx) http.Handler

NewV1Handler returns a handle for V1 API

func NewWebsocketHandler

func NewWebsocketHandler(wsTx <-chan []byte, wsRx chan<- []byte, newConn chan<- bool) http.Handler

NewWebsocketHandler returns a new websocket handler. The wsTx channel is used to send data out the websocket, and the newConn channel is used to signal back to the caller that a new client has connected, and the initial data set needs to be sent over.

func Server

func Server(
	port string,
	dbInst *db.Db,
	influx *db.Influx,
	getAsset func(string) []byte,
	filesystem http.FileSystem,
	debug bool) error

Server starts a API server instance

func ShiftPath

func ShiftPath(p string) (head, tail string)

ShiftPath is used to extract on segement of URL for processing

Types

type App

type App struct {
	PublicHandler http.Handler
	IndexHandler  http.Handler
	V1ApiHandler  http.Handler
	Debug         bool
}

App is a struct that implements http.Handler interface

func (*App) ServeHTTP

func (h *App) ServeHTTP(res http.ResponseWriter, req *http.Request)

Top level handler for http requests in the coap-server process

type CoapServer

type CoapServer struct {
	// contains filtered or unexported fields
}

CoapServer manages all the coap requests for this platform

func NewCoapServer

func NewCoapServer(port string) *CoapServer

NewCoapServer creates a new coap server

func (*CoapServer) Start

func (cs *CoapServer) Start() error

Start the coap server

type Devices

type Devices struct {
	// contains filtered or unexported fields
}

Devices handles device requests

func (*Devices) ServeHTTP

func (h *Devices) ServeHTTP(res http.ResponseWriter, req *http.Request)

Top level handler for http requests in the coap-server process

type IndexHandler

type IndexHandler struct {
	// contains filtered or unexported fields
}

IndexHandler is used to serve the index page

func (*IndexHandler) ServeHTTP

func (h *IndexHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

type V1

type V1 struct {
	DevicesHandler http.Handler
}

V1 handles v1 api requests

func (*V1) ServeHTTP

func (h *V1) ServeHTTP(res http.ResponseWriter, req *http.Request)

Top level handler for http requests in the coap-server process

type WebsocketHandler

type WebsocketHandler struct {
	// contains filtered or unexported fields
}

WebsocketHandler handles websocket connections

func (*WebsocketHandler) ServeHTTP

func (h *WebsocketHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

Jump to

Keyboard shortcuts

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