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 ¶ added in v0.0.12
func NewNodesHandler(v RequestValidator, authToken string, nc *nats.Conn) http.Handler
NewNodesHandler returns a new node handler
func NewSendPoints ¶ added in v0.0.11
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 AlwaysValid ¶ added in v0.0.5
type AlwaysValid struct{}
AlwaysValid is used to disable authentication
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 ¶ added in v0.0.5
type Auth struct {
// contains filtered or unexported fields
}
Auth handles user authentication requests.
func NewAuthHandler ¶ added in v0.0.5
func NewAuthHandler(nc *nats.Conn) Auth
NewAuthHandler returns a new authentication handler using the given key.
type Authorizer ¶ added in v0.0.5
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 ¶ added in v0.0.5
HTTPLogger can be used to log http requests
func NewHTTPLogger ¶ added in v0.0.5
func NewHTTPLogger(prefix string) *HTTPLogger
NewHTTPLogger returns a http logger
type Key ¶ added in v0.0.5
type Key struct {
// contains filtered or unexported fields
}
Key provides a key for signing authentication tokens.
func (Key) NewToken ¶ added in v0.0.5
NewToken returns a new authentication token signed by the Key.
type NodeCopy ¶ added in v0.0.23
NodeCopy is a data structured used in the /node/:id/parents api call
type NodeDelete ¶ added in v0.0.23
type NodeDelete struct {
Parent string
}
NodeDelete is a data structure used with /node/:id DELETE call
type NodeMove ¶ added in v0.0.15
NodeMove is a data structure used in the /node/:id/parents api call
type Nodes ¶ added in v0.0.12
type Nodes struct {
// contains filtered or unexported fields
}
Nodes handles node requests
type Point ¶ added in v0.0.11
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 ¶ added in v0.0.5
RequestValidator validates an HTTP request.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server represents the HTTP API server
type ServerArgs ¶ added in v0.0.5
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