commands: Renamed Response#Value to Response#Output
Matt Bell committed
Nov 3, 2014 at 15:47 UTC
69a56de0403fdf87623d3b3ef96d94da09d373da
4 files changed
+10
-10
commands/http/client.go
+2
-2
@@ -80,7 +80,7 @@ func Send(req cmds.Request) (cmds.Response, error) {
80
contentType = strings.Split(contentType, ";")[0]
81
82
if contentType == "application/octet-stream" {
83
- res.SetValue(httpRes.Body)
83
+ res.SetOutput(httpRes.Body)
84
return res, nil
85
}
86
@@ -120,7 +120,7 @@ func Send(req cmds.Request) (cmds.Response, error) {
120
return nil, err
121
}
122
123
- res.SetValue(v)
123
+ res.SetOutput(v)
124
}
125
126
if len(userEncoding) > 0 {
commands/http/handler.go
+1
-1
@@ -38,7 +38,7 @@ func (i Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
38
res := i.Root.Call(req)
39
40
// set the Content-Type based on res output
41
- if _, ok := res.Value().(io.Reader); ok {
41
+ if _, ok := res.Output().(io.Reader); ok {
42
// TODO: set based on actual Content-Type of file
43
w.Header().Set("Content-Type", "application/octet-stream")
44
} else {
commands/response.go
+6
-6
@@ -49,13 +49,13 @@ var marshallers = map[EncodingType]Marshaller{
49
if res.Error() != nil {
50
return json.Marshal(res.Error())
51
}
52
- return json.Marshal(res.Value())
52
+ return json.Marshal(res.Output())
53
},
54
XML: func(res Response) ([]byte, error) {
55
if res.Error() != nil {
56
return xml.Marshal(res.Error())
57
}
58
- return xml.Marshal(res.Value())
58
+ return xml.Marshal(res.Output())
59
},
60
Text: func(res Response) ([]byte, error) {
61
format := res.Request().Command().Format
@@ -83,8 +83,8 @@ type Response interface {
83
Error() *Error
84
85
// Sets/Returns the response value
86
- SetValue(interface{})
87
- Value() interface{}
86
+ SetOutput(interface{})
87
+ Output() interface{}
88
89
// Marshal marshals out the response into a buffer. It uses the EncodingType
90
// on the Request to chose a Marshaller (Codec).
@@ -102,11 +102,11 @@ func (r *response) Request() Request {
102
return r.req
103
}
104
105
-func (r *response) Value() interface{} {
105
+func (r *response) Output() interface{} {
106
return r.value
107
}
108
109
-func (r *response) SetValue(v interface{}) {
109
+func (r *response) SetOutput(v interface{}) {
110
r.value = v
111
}
112
commands/response_test.go
+1
-1
@@ -14,7 +14,7 @@ func TestMarshalling(t *testing.T) {
14
req := NewEmptyRequest()
15
16
res := NewResponse(req)
17
- res.SetValue(TestOutput{"beep", "boop", 1337})
17
+ res.SetOutput(TestOutput{"beep", "boop", 1337})
18
19
// get command global options so we can set the encoding option
20
cmd := Command{}