Rename /commands to /command

Make it a verb not a GET fetch
This commit is contained in:
Marc Di Luzio 2020-06-05 22:29:51 +01:00
parent 9d57f48f98
commit 9ae1f50f46
5 changed files with 27 additions and 27 deletions

View file

@ -67,22 +67,22 @@ type SpawnResponse struct {
}
// ==============================
// API: /commands method: POST
// API: /command method: POST
// Commands issues a set of commands from the user
func (s Server) Commands(d CommandsData) (r CommandsResponse, err error) {
err = s.POST("commands", d, &r)
// Command issues a set of commands from the user
func (s Server) Command(d CommandData) (r CommandResponse, err error) {
err = s.POST("command", d, &r)
return
}
// CommandsData is a set of commands to execute in order
type CommandsData struct {
// CommandData is a set of commands to execute in order
type CommandData struct {
Id string `json:"id"`
Commands []Command `json:"commands"`
}
// CommandsResponse is the response to be sent back
type CommandsResponse struct {
// CommandResponse is the response to be sent back
type CommandResponse struct {
Success bool `json:"success"`
Error string `json:"error,omitempty"`
}

View file

@ -55,7 +55,7 @@ func TestServer_Spawn(t *testing.T) {
assert.True(t, r2.Success)
}
func TestServer_Commands(t *testing.T) {
func TestServer_Command(t *testing.T) {
d1 := RegisterData{
Name: uuid.New().String(),
}
@ -71,7 +71,7 @@ func TestServer_Commands(t *testing.T) {
assert.NoError(t, err)
assert.True(t, r2.Success)
c := CommandsData{
c := CommandData{
Id: r1.Id,
Commands: []Command{
{
@ -81,7 +81,7 @@ func TestServer_Commands(t *testing.T) {
},
},
}
r3, err := server.Commands(c)
r3, err := server.Command(c)
assert.NoError(t, err)
assert.True(t, r3.Success)
}