Drop unnecessary api parameters
This commit is contained in:
parent
d0176c313e
commit
77dd6dbae3
4
api.go
4
api.go
|
@ -31,6 +31,10 @@ func Api(bot *Master) {
|
||||||
decoder := json.NewDecoder(req.Body)
|
decoder := json.NewDecoder(req.Body)
|
||||||
var body map[string]interface{}
|
var body map[string]interface{}
|
||||||
decoder.Decode(&body)
|
decoder.Decode(&body)
|
||||||
|
if len(body) == 0 {
|
||||||
|
body = map[string]interface{}{}
|
||||||
|
}
|
||||||
|
body["robotname"] = params["robotname"]
|
||||||
return a.executeRobotCommand(bot, params, body)
|
return a.executeRobotCommand(bot, params, body)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/hybridgroup/gobot"
|
"github.com/hybridgroup/gobot"
|
||||||
"github.com/hybridgroup/gobot-sphero"
|
"github.com/hybridgroup/gobot-sphero"
|
||||||
)
|
)
|
||||||
|
@ -9,9 +8,7 @@ import (
|
||||||
var Master *gobot.Master = gobot.GobotMaster()
|
var Master *gobot.Master = gobot.GobotMaster()
|
||||||
|
|
||||||
func TurnBlue(params map[string]interface{}) bool {
|
func TurnBlue(params map[string]interface{}) bool {
|
||||||
name := params["name"].(string)
|
sphero := Master.FindRobotDevice(params["robotname"].(string), "sphero")
|
||||||
device := params["device"].(string)
|
|
||||||
sphero := Master.FindRobotDevice(name, device)
|
|
||||||
gobot.Call(sphero.Driver, "SetRGB", uint8(0), uint8(0), uint8(255))
|
gobot.Call(sphero.Driver, "SetRGB", uint8(0), uint8(0), uint8(255))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue