@@ -104,23 +104,13 @@ func (c *Command) Call(req Request, re ResponseEmitter) error {
104
104
switch run := cmd .Run .(type ) {
105
105
default :
106
106
panic (fmt .Sprintf ("unexpected type: %T" , run ))
107
- case func (Request , ResponseEmitter ) error :
108
- err := run (req , re )
109
- if err != nil {
110
- return err
111
- }
112
-
113
- return nil
114
107
case func (Request , Response ):
115
- res := FakeResponse (re )
116
-
117
- run (req , res )
118
- if res .Error () != nil {
119
- return res .Error ()
120
- }
121
-
122
- output = res .Output ()
108
+ // TODO this shouldn't happen; need to fix tests
109
+ return nil
110
+ case func (Request , ResponseEmitter ):
111
+ run (req , re )
123
112
113
+ return nil
124
114
// legacy:
125
115
case oldcmds.Function , func (oldcmds.Request , oldcmds.Response ):
126
116
var (
@@ -180,12 +170,12 @@ func (c *Command) Call(req Request, re ResponseEmitter) error {
180
170
} else if ch , ok := output .(chan interface {}); ok {
181
171
output = (<- chan interface {})(ch )
182
172
} else {
183
- res .SetError (ErrIncorrectType , oldcmds . ErrorType ( ErrNormal ) )
173
+ re .SetError (ErrIncorrectType , ErrNormal )
184
174
return ErrIncorrectType
185
175
}
186
176
187
177
go func () {
188
- for v := range ch {
178
+ for v := range output .( <- chan interface {}) {
189
179
re .Emit (v )
190
180
}
191
181
}()
@@ -196,12 +186,12 @@ func (c *Command) Call(req Request, re ResponseEmitter) error {
196
186
expectedType := reflect .TypeOf (cmd .Type )
197
187
198
188
if actualType != expectedType {
199
- res .SetError (ErrIncorrectType , oldcmds . ErrorType ( ErrNormal ) )
189
+ re .SetError (ErrIncorrectType , ErrNormal )
200
190
return ErrIncorrectType
201
191
}
202
192
}
203
193
204
- re .Emit (v )
194
+ re .Emit (output )
205
195
}
206
196
207
197
return nil
0 commit comments