commands: Removed inpout stream from Request

This commit is contained in:
Matt Bell 2014-11-02 16:59:52 -08:00 committed by Juan Batiz-Benet
parent 827f1dd0b0
commit 3a8d60cc61
4 changed files with 6 additions and 20 deletions

View File

@ -26,7 +26,7 @@ func Parse(input []string, roots ...*cmds.Command) (cmds.Request, *cmds.Command,
length := len(path)
if length > maxLength {
maxLength = length
req = cmds.NewRequest(path, opts, args, nil, cmd)
req = cmds.NewRequest(path, opts, args, cmd)
root = r
}
}

View File

@ -51,7 +51,7 @@ func Send(req cmds.Request) (cmds.Response, error) {
}
}
httpRes, err := http.Post(url+query, "application/octet-stream", req.Stream())
httpRes, err := http.Post(url+query, "application/octet-stream", nil)
if err != nil {
return nil, err
}

View File

@ -34,7 +34,7 @@ func Parse(r *http.Request, root *cmds.Command) (cmds.Request, error) {
opts, args2 := parseOptions(r)
args = append(args, args2...)
return cmds.NewRequest(path, opts, args, nil, cmd), nil
return cmds.NewRequest(path, opts, args, cmd), nil
}
func parseOptions(r *http.Request) (map[string]interface{}, []interface{}) {

View File

@ -2,7 +2,6 @@ package commands
import (
"fmt"
"io"
"reflect"
"strconv"
@ -25,8 +24,6 @@ type Request interface {
Options() map[string]interface{}
SetOption(name string, val interface{})
Arguments() []interface{} // TODO: make argument value type instead of using interface{}
Stream() io.Reader
SetStream(io.Reader)
Context() *Context
SetContext(Context)
Command() *Command
@ -38,7 +35,6 @@ type request struct {
path []string
options optMap
arguments []interface{}
in io.Reader
cmd *Command
ctx Context
}
@ -73,16 +69,6 @@ func (r *request) Arguments() []interface{} {
return r.arguments
}
// Stream returns the input stream Reader
func (r *request) Stream() io.Reader {
return r.in
}
// SetStream sets the value of the input stream Reader
func (r *request) SetStream(in io.Reader) {
r.in = in
}
func (r *request) Context() *Context {
return &r.ctx
}
@ -161,11 +147,11 @@ func (r *request) ConvertOptions(options map[string]Option) error {
// NewEmptyRequest initializes an empty request
func NewEmptyRequest() Request {
return NewRequest(nil, nil, nil, nil, nil)
return NewRequest(nil, nil, nil, nil)
}
// NewRequest returns a request initialized with given arguments
func NewRequest(path []string, opts optMap, args []interface{}, in io.Reader, cmd *Command) Request {
func NewRequest(path []string, opts optMap, args []interface{}, cmd *Command) Request {
if path == nil {
path = make([]string, 0)
}
@ -175,5 +161,5 @@ func NewRequest(path []string, opts optMap, args []interface{}, in io.Reader, cm
if args == nil {
args = make([]interface{}, 0)
}
return &request{path, opts, args, in, cmd, Context{}}
return &request{path, opts, args, cmd, Context{}}
}