mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-20 19:19:06 +08:00
refactor(commands) swap argument order to match Http(w, r) idiom
This commit is contained in:

committed by
Juan Batiz-Benet

parent
b1bf60b877
commit
4911dc069a
@ -12,7 +12,7 @@ var log = u.Logger("command")
|
|||||||
|
|
||||||
// Function is the type of function that Commands use.
|
// Function is the type of function that Commands use.
|
||||||
// It reads from the Request, and writes results to the Response.
|
// 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
|
// Formatter is a function that takes in a Response, and returns a human-readable string
|
||||||
// (or an error on failure)
|
// (or an error on failure)
|
||||||
@ -63,7 +63,7 @@ func (c *Command) Call(req Request) Response {
|
|||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Run(req, res)
|
cmd.Run(res, req)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ func TestOptionValidation(t *testing.T) {
|
|||||||
Option{[]string{"b", "beep"}, Int},
|
Option{[]string{"b", "beep"}, Int},
|
||||||
Option{[]string{"B", "boop"}, String},
|
Option{[]string{"B", "boop"}, String},
|
||||||
},
|
},
|
||||||
Run: func(req Request, res Response) {},
|
Run: func(res Response, req Request) {},
|
||||||
}
|
}
|
||||||
|
|
||||||
req := NewEmptyRequest()
|
req := NewEmptyRequest()
|
||||||
@ -79,7 +79,7 @@ func TestOptionValidation(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestRegistration(t *testing.T) {
|
func TestRegistration(t *testing.T) {
|
||||||
noop := func(req Request, res Response) {}
|
noop := func(res Response, req Request) {}
|
||||||
|
|
||||||
cmdA := &Command{
|
cmdA := &Command{
|
||||||
Options: []Option{
|
Options: []Option{
|
||||||
|
Reference in New Issue
Block a user