hybridgroup.gobot/examples/hello_api.go

26 lines
450 B
Go

package main
import (
"fmt"
"github.com/hybridgroup/gobot"
)
func Hello(params map[string]interface{}) string {
name := params["name"].(string)
return fmt.Sprintf("hi %v", name)
}
func main() {
master := gobot.GobotMaster()
api := gobot.Api(master)
api.Port = "4000"
hello := new(gobot.Robot)
hello.Name = "hello"
hello.Commands = map[string]interface{}{"Hello": Hello}
master.Robots = append(master.Robots, hello)
master.Start()
}