commands: Removed inpout stream from Request
Matt Bell committed
Nov 2, 2014 at 16:59 UTC
3a8d60cc61d3ece8a79625f987286d24f220e7c7
4 files changed
+6
-20
commands/cli/parse.go
+1
-1
@@ -26,7 +26,7 @@ func Parse(input []string, roots ...*cmds.Command) (cmds.Request, *cmds.Command,
26
length := len(path)
27
if length > maxLength {
28
maxLength = length
29
- req = cmds.NewRequest(path, opts, args, nil, cmd)
29
+ req = cmds.NewRequest(path, opts, args, cmd)
30
root = r
31
}
32
}
commands/http/client.go
+1
-1
@@ -51,7 +51,7 @@ func Send(req cmds.Request) (cmds.Response, error) {
51
}
52
}
53
54
- httpRes, err := http.Post(url+query, "application/octet-stream", req.Stream())
54
+ httpRes, err := http.Post(url+query, "application/octet-stream", nil)
55
if err != nil {
56
return nil, err
57
}
commands/http/parse.go
+1
-1
@@ -34,7 +34,7 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) {
34
opts, args2 := parseOptions(r)
35
args = append(args, args2...)
36
37
- return cmds.NewRequest(path, opts, args, nil, cmd), nil
37
+ return cmds.NewRequest(path, opts, args, cmd), nil
38
}
39
40
func parseOptions(r *http.Request) (map[string]interface{}, []interface{}) {
commands/request.go
+3
-17
@@ -2,7 +2,6 @@ package commands
2
3
import (
4
"fmt"
5
- "io"
5
"reflect"
6
"strconv"
7
@@ -25,8 +24,6 @@ type Request interface {
24
Options() map[string]interface{}
25
SetOption(name string, val interface{})
26
Arguments() []interface{} // TODO: make argument value type instead of using interface{}
28
- Stream() io.Reader
29
- SetStream(io.Reader)
27
Context() *Context
28
SetContext(Context)
29
Command() *Command
@@ -38,7 +35,6 @@ type request struct {
35
path []string
36
options optMap
37
arguments []interface{}
41
- in io.Reader
38
cmd *Command
39
ctx Context
40
}
@@ -73,16 +69,6 @@ func (r *request) Arguments() []interface{} {
69
return r.arguments
70
}
71
76
-// Stream returns the input stream Reader
77
-func (r *request) Stream() io.Reader {
78
- return r.in
79
-}
80
-
81
-// SetStream sets the value of the input stream Reader
82
-func (r *request) SetStream(in io.Reader) {
83
- r.in = in
84
-}
85
-
72
func (r *request) Context() *Context {
73
return &r.ctx
74
}
@@ -161,11 +147,11 @@ func (r *request) ConvertOptions(options map[string]Option) error {
147
148
// NewEmptyRequest initializes an empty request
149
func NewEmptyRequest() Request {
164
- return NewRequest(nil, nil, nil, nil, nil)
150
+ return NewRequest(nil, nil, nil, nil)
151
}
152
153
// NewRequest returns a request initialized with given arguments
168
-func NewRequest(path []string, opts optMap, args []interface{}, in io.Reader, cmd *Command) Request {
154
+func NewRequest(path []string, opts optMap, args []interface{}, cmd *Command) Request {
155
if path == nil {
156
path = make([]string, 0)
157
}
@@ -175,5 +161,5 @@ func NewRequest(path []string, opts optMap, args []interface{}, in io.Reader, cm
161
if args == nil {
162
args = make([]interface{}, 0)
163
}
178
- return &request{path, opts, args, in, cmd, Context{}}
164
+ return &request{path, opts, args, cmd, Context{}}
165
}