Documentation
¶
Overview ¶
Package api implments the SIOT http interface.
Index ¶
- func NewAppHandler(args ServerArgs) http.Handler
- func NewNodesHandler(v RequestValidator, authToken string, nc *nats.Conn) http.Handler
- func NewSendPoints(portalURL, deviceID, authToken string, timeout time.Duration, debug bool) func(data.Points) error
- func NewV1Handler(args ServerArgs) http.Handler
- func ShiftPath(p string) (head, tail string)
- type AlwaysValid
- type App
- type Auth
- type Authorizer
- type CoapServer
- type HTTPLogger
- type Key
- type NodeCopy
- type NodeDelete
- type NodeMove
- type Nodes
- type Point
- type RequestValidator
- type Server
- type ServerArgs
- type V1
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewAppHandler ¶
func NewAppHandler(args ServerArgs) http.Handler
NewAppHandler returns a new application (root) http handler
func NewNodesHandler ¶
NewNodesHandler returns a new node handler
func NewSendPoints ¶
func NewSendPoints(portalURL, deviceID, authToken string, timeout time.Duration, debug bool) func(data.Points) error
NewSendPoints returns a function that can be used to send points to a SimpleIoT portal instance
func NewV1Handler ¶
func NewV1Handler(args ServerArgs) http.Handler
NewV1Handler returns a handle for V1 API
Types ¶
type App ¶
type App struct {
PublicHandler http.Handler
V1ApiHandler http.Handler
WebsocketProxy http.Handler
}
App is a struct that implements http.Handler interface
type Auth ¶
type Auth struct {
// contains filtered or unexported fields
}
Auth handles user authentication requests.
func NewAuthHandler ¶
NewAuthHandler returns a new authentication handler using the given key.
type Authorizer ¶
type Authorizer interface {
NewToken(id string) (string, error)
Valid(req *http.Request) (bool, string)
}
Authorizer defines a mechanism needed to authorize stuff
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
type HTTPLogger ¶
HTTPLogger can be used to log http requests
func NewHTTPLogger ¶
func NewHTTPLogger(prefix string) *HTTPLogger
NewHTTPLogger returns a http logger
type Key ¶
type Key struct {
// contains filtered or unexported fields
}
Key provides a key for signing authentication tokens.
type NodeDelete ¶
type NodeDelete struct {
Parent string
}
NodeDelete is a data structure used with /node/:id DELETE call
type Nodes ¶
type Nodes struct {
// contains filtered or unexported fields
}
Nodes handles node requests
type Point ¶
type Point struct {
// Type of point (voltage, current, key, etc)
Type string `json:"type,omitempty" influx:"type,tag"`
// Key of the device that provided the point
Key string `json:"key,omitempty" influx:"key,tag"`
// Average OR
// Instantaneous analog or digital value of the point.
// 0 and 1 are used to represent digital values
Value float64 `json:"value,omitempty" influx:"value"`
// Time the point was taken
Time *time.Time `json:"time,omitempty" gob:"-" influx:"time"`
// Duration over which the point was taken
Duration time.Duration `json:"duration,omitempty" influx:"duration"`
}
Point is a custom value of data.Point with Time set to a pointer. This allows omitempty to work for zero timestamps to avoid bloating JSON packets.
type RequestValidator ¶
RequestValidator validates an HTTP request.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the HTTP API server
type ServerArgs ¶
type ServerArgs struct {
Port string
Filesystem http.FileSystem
Debug bool
JwtAuth Authorizer
AuthToken string
NatsWSPort int
Nc *nats.Conn
}
ServerArgs can be used to pass arguments to the server subsystem