From 4911dc069ac4a9271f994b68f07e4a8cbb08f30e Mon Sep 17 00:00:00 2001 From: Brian Tiger Chow Date: Wed, 29 Oct 2014 01:42:52 -0700 Subject: [PATCH] refactor(commands) swap argument order to match Http(w, r) idiom --- commands/command.go | 4 ++-- commands/command_test.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/commands/command.go b/commands/command.go index cee08307f..0521d0baf 100644 --- a/commands/command.go +++ b/commands/command.go @@ -12,7 +12,7 @@ var log = u.Logger("command") // Function is the type of function that Commands use. // It reads from the Request, and writes results to the Response. -type Function func(Request, Response) +type Function func(Response, Request) // Formatter is a function that takes in a Response, and returns a human-readable string // (or an error on failure) @@ -63,7 +63,7 @@ func (c *Command) Call(req Request) Response { return res } - cmd.Run(req, res) + cmd.Run(res, req) return res } diff --git a/commands/command_test.go b/commands/command_test.go index 197b75e3a..e97391a0c 100644 --- a/commands/command_test.go +++ b/commands/command_test.go @@ -8,7 +8,7 @@ func TestOptionValidation(t *testing.T) { Option{[]string{"b", "beep"}, Int}, Option{[]string{"B", "boop"}, String}, }, - Run: func(req Request, res Response) {}, + Run: func(res Response, req Request) {}, } req := NewEmptyRequest() @@ -79,7 +79,7 @@ func TestOptionValidation(t *testing.T) { } func TestRegistration(t *testing.T) { - noop := func(req Request, res Response) {} + noop := func(res Response, req Request) {} cmdA := &Command{ Options: []Option{