commands: Allow setting Request fields in NewRequest
Matt Bell committed
Oct 15, 2014 at 16:35 UTC
7a36278dbc24955b715b07eac4f311ade7e54719
1 file changed
+10
-5
commands/request.go
+10
-5
@@ -96,10 +96,15 @@ func (r *Request) convertOptions(options map[string]Option) error {
96
return nil
97
}
98
99
-func NewRequest() *Request {
100
- return &Request{
101
- make([]string, 0),
102
- make(map[string]interface{}),
103
- make([]string, 0),
99
+func NewRequest(path []string, opts map[string]interface{}, args []string) *Request {
100
+ if path == nil {
101
+ path = make([]string, 0)
102
}
103
+ if opts == nil {
104
+ opts = make(map[string]interface{})
105
+ }
106
+ if args == nil {
107
+ args = make([]string, 0)
108
+ }
109
+ return &Request{path, opts, args}
110
}