From c0b28dc19dd50792aff5eec000ddb066b2fff9be Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Mon, 20 Oct 2014 14:38:09 -0700 Subject: [PATCH] commands: Added input stream field to Request --- commands/request.go | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/commands/request.go b/commands/request.go index 1571a1b93..6259e94ba 100644 --- a/commands/request.go +++ b/commands/request.go @@ -4,6 +4,7 @@ import ( "fmt" "reflect" "strconv" + "io" ) type optMap map[string]interface{} @@ -14,6 +15,7 @@ type Request interface { Option(name string) (interface{}, bool) SetOption(name string, val interface{}) Arguments() []string + Stream() io.Reader ConvertOptions(options map[string]Option) error } @@ -22,6 +24,7 @@ type request struct { path []string options optMap arguments []string + in io.Reader } // Path returns the command path of this request @@ -45,6 +48,11 @@ func (r *request) Arguments() []string { return r.arguments } +// Stream returns the input stream Reader +func (r *request) Stream() io.Reader { + return r.in +} + type converter func(string) (interface{}, error) var converters = map[reflect.Kind]converter{ @@ -111,11 +119,11 @@ func (r *request) ConvertOptions(options map[string]Option) error { // NewEmptyRequest initializes an empty request func NewEmptyRequest() Request { - return NewRequest(nil, nil, nil) + return NewRequest(nil, nil, nil, nil) } // NewRequest returns a request initialized with given arguments -func NewRequest(path []string, opts optMap, args []string) Request { +func NewRequest(path []string, opts optMap, args []string, in io.Reader) Request { if path == nil { path = make([]string, 0) } @@ -125,5 +133,5 @@ func NewRequest(path []string, opts optMap, args []string) Request { if args == nil { args = make([]string, 0) } - return &request{path, opts, args} + return &request{path, opts, args, in} }