forked from hybridgroup/gobot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Javier Cervantes
committed
Oct 22, 2014
1 parent
6d2e25b
commit ad96293
Showing
10 changed files
with
141 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
Package api provides functionally to expose your gobot programs | ||
to other by using starting a web server and adding commands. | ||
Example: | ||
package main | ||
import ( | ||
"fmt" | ||
"github.com/hybridgroup/gobot" | ||
"github.com/hybridgroup/gobot/api" | ||
) | ||
func main() { | ||
gbot := gobot.NewGobot() | ||
// Starts the API server on default port 3000 | ||
api.NewAPI(gbot).Start() | ||
// Accessible via http://localhost:3000/api/commands/say_hello | ||
gbot.AddCommand("say_hello", func(params map[string]interface{}) interface{} { | ||
return "Master says hello!" | ||
}) | ||
hello := gbot.AddRobot(gobot.NewRobot("Eve")) | ||
// Accessible via http://localhost:3000/robots/Eve/commands/say_hello | ||
hello.AddCommand("say_hello", func(params map[string]interface{}) interface{} { | ||
return fmt.Sprintf("%v says hello!", hello.Name) | ||
}) | ||
gbot.Start() | ||
} | ||
It follows Common Protocol for Programming Physical Input and Output (CPPP-IO) spec: | ||
https://github.com/hybridgroup/cppp-io | ||
*/ | ||
package api |
Oops, something went wrong.