webthing

package module
Version: v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2019 License: MPL-2.0 Imports: 5 Imported by: 0

README

WEBTHING-GO

Codacy Badge

GitHub forks license GitHub version GoDoc Build Status pulls Automated Builds Build Status Go Report Card codebeat badge

USAGE

To get started look at "example" directory:

go version
#| go version go1.10.4 linux/amd64

go get github.com/rzr/webthing-go

cd ~/go/src/github.com/rzr/webthing-go
go run example/simplest-webthing-go/simplest-thing.go
#| Listening: :8888

curl http://localhost:8888/properties
#| {"on":false}

curl -X PUT --data '{"on": true}'  http://localhost:8888/properties/on
#| {"on":true}

curl http://localhost:8888/properties/on
#| {"on":true}

curl http://localhost:8888 | jq -M .
#| { ...
#| "title": "ActuatorExample"
#| }

To import published module just use this alias:

import (
	webthing "github.com/rzr/webthing-go"
)

RESOURCES

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Property

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

Property is made of value(s)

func NewProperty

func NewProperty(name string, valuetype string, value interface{}, handler func(interface{})) *Property

NewProperty contructs and assign value

type Server

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

Server is an HTTP server made for webthings model

func NewServer

func NewServer(thing *Thing, port int) *Server

NewServer constructs an http server to be started

func (Server) Start

func (server Server) Start()

Start listening for incoming requests and process using handlers

type Thing

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

Thing is made of Property(ies)

func NewThing

func NewThing(id string, title string, types []string, description string) *Thing

NewThing construct without properties

func (Thing) AddProperty

func (thing Thing) AddProperty(property *Property)

AddProperty adds property (along values) to thing

type Value

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

Value is a multitypes placeholder, only one is used

Source Files

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

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