@cryptotaxi247 / kubo / commits / 4911dc069

refactor(commands) swap argument order to match Http(w, r) idiom

Brian Tiger Chow committed Oct 29, 2014 at 01:42 UTC 4911dc069ac4a9271f994b68f07e4a8cbb08f30e
2 files changed +4 -4
commands/command.go
+2 -2
@@ -12,7 +12,7 @@ var log = u.Logger("command")
12
13 // Function is the type of function that Commands use.
14 // It reads from the Request, and writes results to the Response.
15 -type Function func(Request, Response)
15 +type Function func(Response, Request)
16
17 // Formatter is a function that takes in a Response, and returns a human-readable string
18 // (or an error on failure)
@@ -63,7 +63,7 @@ func (c *Command) Call(req Request) Response {
63 return res
64 }
65
66 - cmd.Run(req, res)
66 + cmd.Run(res, req)
67
68 return res
69 }
commands/command_test.go
+2 -2
@@ -8,7 +8,7 @@ func TestOptionValidation(t *testing.T) {
8 Option{[]string{"b", "beep"}, Int},
9 Option{[]string{"B", "boop"}, String},
10 },
11 - Run: func(req Request, res Response) {},
11 + Run: func(res Response, req Request) {},
12 }
13
14 req := NewEmptyRequest()
@@ -79,7 +79,7 @@ func TestOptionValidation(t *testing.T) {
79 }
80
81 func TestRegistration(t *testing.T) {
82 - noop := func(req Request, res Response) {}
82 + noop := func(res Response, req Request) {}
83
84 cmdA := &Command{
85 Options: []Option{