Skip to content

Commit

Permalink
api: settled on StartWithoutDefaults() as the method to start API wit…
Browse files Browse the repository at this point in the history
…hout default routes

Signed-off-by: Ron Evans <[email protected]>
  • Loading branch information
deadprogram committed Aug 17, 2018
1 parent 6eec38c commit 4eb7b17
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
6 changes: 4 additions & 2 deletions api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ func (a *API) Start() {
a.start(a)
}

// StartRaw initializes the api without setting up any routes. Good for custom web interfaces.
func (a *API) StartRaw() {
// StartWithoutDefaults initializes the api without setting up the default routes.
// Good for custom web interfaces.
//
func (a *API) StartWithoutDefaults() {
a.start(a)
}

Expand Down
4 changes: 2 additions & 2 deletions api/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ func initTestAPI() *API {
return a
}

func TestStartRaw(t *testing.T) {
func TestStartWithoutDefaults(t *testing.T) {
log.SetOutput(NullReadWriteCloser{})
g := gobot.NewMaster()
a := NewAPI(g)
a.start = func(m *API) {}

a.Get("/", func(res http.ResponseWriter, req *http.Request) {})
a.StartRaw()
a.StartWithoutDefaults()

request, _ := http.NewRequest("GET", "/", nil)
response := httptest.NewRecorder()
Expand Down
4 changes: 2 additions & 2 deletions examples/hello_api_custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func main() {
res.Write([]byte(msg))
})

// starts the API without the "standard" C2PIO API or Robeaux web interface.
a.StartRaw()
// starts the API without the default C2PIO API and Robeaux web interface.
a.StartWithoutDefaults()

master.AddRobot(gobot.NewRobot("hello"))

Expand Down
7 changes: 4 additions & 3 deletions examples/hello_api_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ func main() {
// add the standard C3PIO API routes manually.
a.AddC3PIORoutes()

// starts the API without adding the Robeaux web interface. However, since the C3PIO API was
// already added manually above, that will be available.
a.StartRaw()
// starts the API without the default C2PIO API and Robeaux web interface.
// However, the C3PIO API was added manually using a.AddC3PIORoutes() which
// means the REST API will be available, but not the web interface.
a.StartWithoutDefaults()

hello := master.AddRobot(gobot.NewRobot("hello"))

Expand Down

0 comments on commit 4eb7b17

Please sign in to comment.