github.com/grpc-ecosystem/grpc-gateway/v2@v2.19.1/examples/internal/server/flow_combination.go (about) 1 package server 2 3 import ( 4 "context" 5 "io" 6 7 examples "github.com/grpc-ecosystem/grpc-gateway/v2/examples/internal/proto/examplepb" 8 ) 9 10 type flowCombinationServer struct{} 11 12 func newFlowCombinationServer() examples.FlowCombinationServer { 13 return &flowCombinationServer{} 14 } 15 16 func (s flowCombinationServer) RpcEmptyRpc(ctx context.Context, req *examples.EmptyProto) (*examples.EmptyProto, error) { 17 return req, nil 18 } 19 20 func (s flowCombinationServer) RpcEmptyStream(req *examples.EmptyProto, stream examples.FlowCombination_RpcEmptyStreamServer) error { 21 return stream.Send(req) 22 } 23 24 func (s flowCombinationServer) StreamEmptyRpc(stream examples.FlowCombination_StreamEmptyRpcServer) error { 25 for { 26 _, err := stream.Recv() 27 if err == io.EOF { 28 break 29 } 30 if err != nil { 31 return err 32 } 33 } 34 return stream.SendAndClose(new(examples.EmptyProto)) 35 } 36 37 func (s flowCombinationServer) StreamEmptyStream(stream examples.FlowCombination_StreamEmptyStreamServer) error { 38 for { 39 _, err := stream.Recv() 40 if err == io.EOF { 41 break 42 } 43 if err != nil { 44 return err 45 } 46 } 47 return stream.Send(new(examples.EmptyProto)) 48 } 49 50 func (s flowCombinationServer) RpcBodyRpc(ctx context.Context, req *examples.NonEmptyProto) (*examples.EmptyProto, error) { 51 return new(examples.EmptyProto), nil 52 } 53 54 func (s flowCombinationServer) RpcPathSingleNestedRpc(ctx context.Context, req *examples.SingleNestedProto) (*examples.EmptyProto, error) { 55 return new(examples.EmptyProto), nil 56 } 57 58 func (s flowCombinationServer) RpcPathNestedRpc(ctx context.Context, req *examples.NestedProto) (*examples.EmptyProto, error) { 59 return new(examples.EmptyProto), nil 60 } 61 62 func (s flowCombinationServer) RpcBodyStream(req *examples.NonEmptyProto, stream examples.FlowCombination_RpcBodyStreamServer) error { 63 return stream.Send(new(examples.EmptyProto)) 64 } 65 66 func (s flowCombinationServer) RpcPathSingleNestedStream(req *examples.SingleNestedProto, stream examples.FlowCombination_RpcPathSingleNestedStreamServer) error { 67 return stream.Send(new(examples.EmptyProto)) 68 } 69 70 func (s flowCombinationServer) RpcPathNestedStream(req *examples.NestedProto, stream examples.FlowCombination_RpcPathNestedStreamServer) error { 71 return stream.Send(new(examples.EmptyProto)) 72 }