diff --git a/api.go b/api.go index 354832c5..2fa48710 100644 --- a/api.go +++ b/api.go @@ -31,6 +31,10 @@ func Api(bot *Master) { decoder := json.NewDecoder(req.Body) var body map[string]interface{} decoder.Decode(&body) + if len(body) == 0 { + body = map[string]interface{}{} + } + body["robotname"] = params["robotname"] return a.executeRobotCommand(bot, params, body) }) diff --git a/examples/sphero_api.go b/examples/sphero_api.go index c67a9014..ae111077 100644 --- a/examples/sphero_api.go +++ b/examples/sphero_api.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "github.com/hybridgroup/gobot" "github.com/hybridgroup/gobot-sphero" ) @@ -9,9 +8,7 @@ import ( var Master *gobot.Master = gobot.GobotMaster() func TurnBlue(params map[string]interface{}) bool { - name := params["name"].(string) - device := params["device"].(string) - sphero := Master.FindRobotDevice(name, device) + sphero := Master.FindRobotDevice(params["robotname"].(string), "sphero") gobot.Call(sphero.Driver, "SetRGB", uint8(0), uint8(0), uint8(255)) return true }