Skip to content

Commit

Permalink
Fixed reply *Rerror bug
Browse files Browse the repository at this point in the history
  • Loading branch information
andeya committed Mar 1, 2018
1 parent 5ddca02 commit 1308a7c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions router.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (r *Router) SetUnknownPull(fn func(UnknownPullCtx) (interface{}, *Rerror),
if rerr != nil {
ctx.handleErr = rerr
rerr.SetToMeta(ctx.output.Meta())
} else if body != nil {
} else {
ctx.output.SetBody(body)
if ctx.output.BodyCodec() == codec.NilCodecId {
ctx.output.SetBodyCodec(ctx.input.BodyCodec())
Expand Down Expand Up @@ -369,13 +369,15 @@ func pullHandlersMaker(pathPrefix string, ctrlStruct interface{}, pluginContaine
obj := pool.Get().(*PullCtrlValue)
*obj.ctxPtr = ctx
rets := methodFunc.Call([]reflect.Value{obj.ctrl, argValue})
ctx.output.SetBody(rets[0].Interface())
rerr, _ := rets[1].Interface().(*Rerror)
if rerr != nil {
ctx.handleErr = rerr
rerr.SetToMeta(ctx.output.Meta())
} else if ctx.output.Body() != nil && ctx.output.BodyCodec() == codec.NilCodecId {
ctx.output.SetBodyCodec(ctx.input.BodyCodec())
} else {
ctx.output.SetBody(rets[0].Interface())
if ctx.output.BodyCodec() == codec.NilCodecId {
ctx.output.SetBodyCodec(ctx.input.BodyCodec())
}
}
pool.Put(obj)
}
Expand Down

0 comments on commit 1308a7c

Please sign in to comment.