From 69a56de0403fdf87623d3b3ef96d94da09d373da Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Mon, 3 Nov 2014 15:47:00 -0800 Subject: [PATCH] commands: Renamed Response#Value to Response#Output --- commands/http/client.go | 4 ++-- commands/http/handler.go | 2 +- commands/response.go | 12 ++++++------ commands/response_test.go | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/commands/http/client.go b/commands/http/client.go index 35aa59ca3..5bd1b08ff 100644 --- a/commands/http/client.go +++ b/commands/http/client.go @@ -80,7 +80,7 @@ func Send(req cmds.Request) (cmds.Response, error) { contentType = strings.Split(contentType, ";")[0] if contentType == "application/octet-stream" { - res.SetValue(httpRes.Body) + res.SetOutput(httpRes.Body) return res, nil } @@ -120,7 +120,7 @@ func Send(req cmds.Request) (cmds.Response, error) { return nil, err } - res.SetValue(v) + res.SetOutput(v) } if len(userEncoding) > 0 { diff --git a/commands/http/handler.go b/commands/http/handler.go index aa636a3af..93e22cf44 100644 --- a/commands/http/handler.go +++ b/commands/http/handler.go @@ -38,7 +38,7 @@ func (i Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { res := i.Root.Call(req) // set the Content-Type based on res output - if _, ok := res.Value().(io.Reader); ok { + if _, ok := res.Output().(io.Reader); ok { // TODO: set based on actual Content-Type of file w.Header().Set("Content-Type", "application/octet-stream") } else { diff --git a/commands/response.go b/commands/response.go index a61e8db96..b628036f8 100644 --- a/commands/response.go +++ b/commands/response.go @@ -49,13 +49,13 @@ var marshallers = map[EncodingType]Marshaller{ if res.Error() != nil { return json.Marshal(res.Error()) } - return json.Marshal(res.Value()) + return json.Marshal(res.Output()) }, XML: func(res Response) ([]byte, error) { if res.Error() != nil { return xml.Marshal(res.Error()) } - return xml.Marshal(res.Value()) + return xml.Marshal(res.Output()) }, Text: func(res Response) ([]byte, error) { format := res.Request().Command().Format @@ -83,8 +83,8 @@ type Response interface { Error() *Error // Sets/Returns the response value - SetValue(interface{}) - Value() interface{} + SetOutput(interface{}) + Output() interface{} // Marshal marshals out the response into a buffer. It uses the EncodingType // on the Request to chose a Marshaller (Codec). @@ -102,11 +102,11 @@ func (r *response) Request() Request { return r.req } -func (r *response) Value() interface{} { +func (r *response) Output() interface{} { return r.value } -func (r *response) SetValue(v interface{}) { +func (r *response) SetOutput(v interface{}) { r.value = v } diff --git a/commands/response_test.go b/commands/response_test.go index 058cead07..ef6240673 100644 --- a/commands/response_test.go +++ b/commands/response_test.go @@ -14,7 +14,7 @@ func TestMarshalling(t *testing.T) { req := NewEmptyRequest() res := NewResponse(req) - res.SetValue(TestOutput{"beep", "boop", 1337}) + res.SetOutput(TestOutput{"beep", "boop", 1337}) // get command global options so we can set the encoding option cmd := Command{}