Skip to content

Commit

Permalink
thrift/register: Provide RequestReader
Browse files Browse the repository at this point in the history
  • Loading branch information
abhinav committed Aug 18, 2021
1 parent 4388d13 commit 4e531d3
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions encoding/thrift/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,10 @@ func BuildProcedures(s Service, opts ...RegisterOption) []transport.Procedure {
proto = rc.Protocol
}

var streamProto stream.Protocol = binary.Default
var streamReqReader stream.RequestReader = binary.Default
if rc.Protocol != nil && rc.NoWire {
if sp, ok := rc.Protocol.(stream.Protocol); ok {
streamProto = sp
if sp, ok := rc.Protocol.(stream.RequestReader); ok {
streamReqReader = sp
}
}

Expand All @@ -116,8 +116,7 @@ func BuildProcedures(s Service, opts ...RegisterOption) []transport.Procedure {
if rc.NoWire {
spec = transport.NewUnaryHandlerSpec(thriftNoWireHandler{
NoWireHandler: method.HandlerSpec.NoWire,
Protocol: streamProto,
Enveloping: rc.Enveloping,
RequestReader: streamReqReader,
})
} else {
spec = transport.NewUnaryHandlerSpec(thriftUnaryHandler{
Expand All @@ -130,8 +129,7 @@ func BuildProcedures(s Service, opts ...RegisterOption) []transport.Procedure {
if rc.NoWire {
spec = transport.NewOnewayHandlerSpec(thriftNoWireHandler{
NoWireHandler: method.HandlerSpec.NoWire,
Protocol: streamProto,
Enveloping: rc.Enveloping,
RequestReader: streamReqReader,
})
} else {
spec = transport.NewOnewayHandlerSpec(thriftOnewayHandler{
Expand Down

0 comments on commit 4e531d3

Please sign in to comment.