diff --git a/Makefile b/Makefile index 3b953942f6d..452d89f47f5 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,8 @@ OPTIONS_GO=$(OPTIONS_PROTO:.proto=.pb.go) PKGMAP=Mgoogle/protobuf/descriptor.proto=$(GO_PLUGIN_PKG)/descriptor,Mexamples/sub/message.proto=$(PKG)/examples/sub EXAMPLES=examples/examplepb/echo_service.proto \ - examples/examplepb/a_bit_of_everything.proto + examples/examplepb/a_bit_of_everything.proto \ + examples/examplepb/flow_combination.proto EXAMPLE_SVCSRCS=$(EXAMPLES:.proto=.pb.go) EXAMPLE_GWSRCS=$(EXAMPLES:.proto=.pb.gw.go) EXAMPLE_DEPS=examples/sub/message.proto diff --git a/examples/examplepb/a_bit_of_everything.pb.gw.go b/examples/examplepb/a_bit_of_everything.pb.gw.go index b2d9f1afa66..d79901fa843 100644 --- a/examples/examplepb/a_bit_of_everything.pb.gw.go +++ b/examples/examplepb/a_bit_of_everything.pb.gw.go @@ -34,11 +34,15 @@ var ( filter_ABitOfEverythingService_Create_0 = &utilities.DoubleArray{Encoding: map[string]int{"float_value": 0, "double_value": 1, "int64_value": 2, "uint64_value": 3, "int32_value": 4, "fixed64_value": 5, "fixed32_value": 6, "bool_value": 7, "string_value": 8, "uint32_value": 9, "sfixed32_value": 10, "sfixed64_value": 11, "sint32_value": 12, "sint64_value": 13}, Base: []int{1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, Check: []int{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}} ) -func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (msg proto.Message, err error) { +func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { var protoReq ABitOfEverything - var val string - var ok bool + var ( + val string + ok bool + err error + _ = err + ) val, ok = pathParams["float_value"] if !ok { @@ -201,17 +205,17 @@ func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOf return client.Create(ctx, &protoReq) } -func request_ABitOfEverythingService_CreateBody_0(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (msg proto.Message, err error) { +func request_ABitOfEverythingService_CreateBody_0(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { var protoReq ABitOfEverything - if err = json.NewDecoder(req.Body).Decode(&protoReq); err != nil { + if err := json.NewDecoder(req.Body).Decode(&protoReq); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) } return client.CreateBody(ctx, &protoReq) } -func request_ABitOfEverythingService_BulkCreate_0(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (msg proto.Message, err error) { +func request_ABitOfEverythingService_BulkCreate_0(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { stream, err := client.BulkCreate(ctx) if err != nil { glog.Errorf("Failed to start streaming: %v", err) @@ -238,11 +242,15 @@ func request_ABitOfEverythingService_BulkCreate_0(ctx context.Context, client AB } -func request_ABitOfEverythingService_Lookup_0(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (msg proto.Message, err error) { +func request_ABitOfEverythingService_Lookup_0(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { var protoReq IdMessage - var val string - var ok bool + var ( + val string + ok bool + err error + _ = err + ) val, ok = pathParams["uuid"] if !ok { @@ -264,15 +272,19 @@ func request_ABitOfEverythingService_List_0(ctx context.Context, client ABitOfEv return client.List(ctx, &protoReq) } -func request_ABitOfEverythingService_Update_0(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (msg proto.Message, err error) { +func request_ABitOfEverythingService_Update_0(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { var protoReq ABitOfEverything - if err = json.NewDecoder(req.Body).Decode(&protoReq); err != nil { + if err := json.NewDecoder(req.Body).Decode(&protoReq); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) } - var val string - var ok bool + var ( + val string + ok bool + err error + _ = err + ) val, ok = pathParams["uuid"] if !ok { @@ -288,11 +300,15 @@ func request_ABitOfEverythingService_Update_0(ctx context.Context, client ABitOf return client.Update(ctx, &protoReq) } -func request_ABitOfEverythingService_Delete_0(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (msg proto.Message, err error) { +func request_ABitOfEverythingService_Delete_0(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { var protoReq IdMessage - var val string - var ok bool + var ( + val string + ok bool + err error + _ = err + ) val, ok = pathParams["uuid"] if !ok { @@ -308,11 +324,15 @@ func request_ABitOfEverythingService_Delete_0(ctx context.Context, client ABitOf return client.Delete(ctx, &protoReq) } -func request_ABitOfEverythingService_Echo_0(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (msg proto.Message, err error) { +func request_ABitOfEverythingService_Echo_0(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { var protoReq sub.StringMessage - var val string - var ok bool + var ( + val string + ok bool + err error + _ = err + ) val, ok = pathParams["value"] if !ok { @@ -328,10 +348,10 @@ func request_ABitOfEverythingService_Echo_0(ctx context.Context, client ABitOfEv return client.Echo(ctx, &protoReq) } -func request_ABitOfEverythingService_Echo_1(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (msg proto.Message, err error) { +func request_ABitOfEverythingService_Echo_1(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { var protoReq sub.StringMessage - if err = json.NewDecoder(req.Body).Decode(&protoReq.Value); err != nil { + if err := json.NewDecoder(req.Body).Decode(&protoReq.Value); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) } @@ -342,7 +362,7 @@ var ( filter_ABitOfEverythingService_Echo_2 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) -func request_ABitOfEverythingService_Echo_2(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (msg proto.Message, err error) { +func request_ABitOfEverythingService_Echo_2(ctx context.Context, client ABitOfEverythingServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { var protoReq sub.StringMessage if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_ABitOfEverythingService_Echo_2); err != nil { diff --git a/examples/examplepb/echo_service.pb.go b/examples/examplepb/echo_service.pb.go index 80a74f5fadd..2727c7546f9 100644 --- a/examples/examplepb/echo_service.pb.go +++ b/examples/examplepb/echo_service.pb.go @@ -8,6 +8,7 @@ Package examplepb is a generated protocol buffer package. It is generated from these files: examples/examplepb/echo_service.proto examples/examplepb/a_bit_of_everything.proto + examples/examplepb/flow_combination.proto It has these top-level messages: SimpleMessage diff --git a/examples/examplepb/echo_service.pb.gw.go b/examples/examplepb/echo_service.pb.gw.go index ec866879832..d9a2a9d02bf 100644 --- a/examples/examplepb/echo_service.pb.gw.go +++ b/examples/examplepb/echo_service.pb.gw.go @@ -29,11 +29,15 @@ var _ = runtime.String var _ = json.Marshal var _ = utilities.PascalFromSnake -func request_EchoService_Echo_0(ctx context.Context, client EchoServiceClient, req *http.Request, pathParams map[string]string) (msg proto.Message, err error) { +func request_EchoService_Echo_0(ctx context.Context, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { var protoReq SimpleMessage - var val string - var ok bool + var ( + val string + ok bool + err error + _ = err + ) val, ok = pathParams["id"] if !ok { @@ -49,10 +53,10 @@ func request_EchoService_Echo_0(ctx context.Context, client EchoServiceClient, r return client.Echo(ctx, &protoReq) } -func request_EchoService_EchoBody_0(ctx context.Context, client EchoServiceClient, req *http.Request, pathParams map[string]string) (msg proto.Message, err error) { +func request_EchoService_EchoBody_0(ctx context.Context, client EchoServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { var protoReq SimpleMessage - if err = json.NewDecoder(req.Body).Decode(&protoReq); err != nil { + if err := json.NewDecoder(req.Body).Decode(&protoReq); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) } diff --git a/examples/examplepb/flow_combination.pb.go b/examples/examplepb/flow_combination.pb.go new file mode 100644 index 00000000000..6a231a0761d --- /dev/null +++ b/examples/examplepb/flow_combination.pb.go @@ -0,0 +1,589 @@ +// Code generated by protoc-gen-go. +// source: examples/examplepb/flow_combination.proto +// DO NOT EDIT! + +package examplepb + +import proto "github.com/golang/protobuf/proto" + +// discarding unused import google_api1 "google/api" + +import ( + context "golang.org/x/net/context" + grpc "google.golang.org/grpc" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal + +type EmptyProto struct { +} + +func (m *EmptyProto) Reset() { *m = EmptyProto{} } +func (m *EmptyProto) String() string { return proto.CompactTextString(m) } +func (*EmptyProto) ProtoMessage() {} + +type NonEmptyProto struct { + A string `protobuf:"bytes,1,opt,name=a" json:"a,omitempty"` + B string `protobuf:"bytes,2,opt,name=b" json:"b,omitempty"` + C string `protobuf:"bytes,3,opt,name=c" json:"c,omitempty"` +} + +func (m *NonEmptyProto) Reset() { *m = NonEmptyProto{} } +func (m *NonEmptyProto) String() string { return proto.CompactTextString(m) } +func (*NonEmptyProto) ProtoMessage() {} + +type UnaryProto struct { + Str string `protobuf:"bytes,1,opt,name=str" json:"str,omitempty"` +} + +func (m *UnaryProto) Reset() { *m = UnaryProto{} } +func (m *UnaryProto) String() string { return proto.CompactTextString(m) } +func (*UnaryProto) ProtoMessage() {} + +type NestedProto struct { + A *UnaryProto `protobuf:"bytes,1,opt,name=a" json:"a,omitempty"` + B string `protobuf:"bytes,2,opt,name=b" json:"b,omitempty"` + C string `protobuf:"bytes,3,opt,name=c" json:"c,omitempty"` +} + +func (m *NestedProto) Reset() { *m = NestedProto{} } +func (m *NestedProto) String() string { return proto.CompactTextString(m) } +func (*NestedProto) ProtoMessage() {} + +func (m *NestedProto) GetA() *UnaryProto { + if m != nil { + return m.A + } + return nil +} + +type SingleNestedProto struct { + A *UnaryProto `protobuf:"bytes,1,opt,name=a" json:"a,omitempty"` +} + +func (m *SingleNestedProto) Reset() { *m = SingleNestedProto{} } +func (m *SingleNestedProto) String() string { return proto.CompactTextString(m) } +func (*SingleNestedProto) ProtoMessage() {} + +func (m *SingleNestedProto) GetA() *UnaryProto { + if m != nil { + return m.A + } + return nil +} + +// Reference imports to suppress errors if they are not otherwise used. +var _ context.Context +var _ grpc.ClientConn + +// Client API for FlowCombination service + +type FlowCombinationClient interface { + RpcEmptyRpc(ctx context.Context, in *EmptyProto, opts ...grpc.CallOption) (*EmptyProto, error) + RpcEmptyStream(ctx context.Context, in *EmptyProto, opts ...grpc.CallOption) (FlowCombination_RpcEmptyStreamClient, error) + StreamEmptyRpc(ctx context.Context, opts ...grpc.CallOption) (FlowCombination_StreamEmptyRpcClient, error) + StreamEmptyStream(ctx context.Context, opts ...grpc.CallOption) (FlowCombination_StreamEmptyStreamClient, error) + RpcBodyRpc(ctx context.Context, in *NonEmptyProto, opts ...grpc.CallOption) (*EmptyProto, error) + RpcPathSingleNestedRpc(ctx context.Context, in *SingleNestedProto, opts ...grpc.CallOption) (*EmptyProto, error) + RpcPathNestedRpc(ctx context.Context, in *NestedProto, opts ...grpc.CallOption) (*EmptyProto, error) + RpcBodyStream(ctx context.Context, in *NonEmptyProto, opts ...grpc.CallOption) (FlowCombination_RpcBodyStreamClient, error) + RpcPathSingleNestedStream(ctx context.Context, in *SingleNestedProto, opts ...grpc.CallOption) (FlowCombination_RpcPathSingleNestedStreamClient, error) + RpcPathNestedStream(ctx context.Context, in *NestedProto, opts ...grpc.CallOption) (FlowCombination_RpcPathNestedStreamClient, error) +} + +type flowCombinationClient struct { + cc *grpc.ClientConn +} + +func NewFlowCombinationClient(cc *grpc.ClientConn) FlowCombinationClient { + return &flowCombinationClient{cc} +} + +func (c *flowCombinationClient) RpcEmptyRpc(ctx context.Context, in *EmptyProto, opts ...grpc.CallOption) (*EmptyProto, error) { + out := new(EmptyProto) + err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.examplepb.FlowCombination/RpcEmptyRpc", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *flowCombinationClient) RpcEmptyStream(ctx context.Context, in *EmptyProto, opts ...grpc.CallOption) (FlowCombination_RpcEmptyStreamClient, error) { + stream, err := grpc.NewClientStream(ctx, &_FlowCombination_serviceDesc.Streams[0], c.cc, "/gengo.grpc.gateway.examples.examplepb.FlowCombination/RpcEmptyStream", opts...) + if err != nil { + return nil, err + } + x := &flowCombinationRpcEmptyStreamClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type FlowCombination_RpcEmptyStreamClient interface { + Recv() (*EmptyProto, error) + grpc.ClientStream +} + +type flowCombinationRpcEmptyStreamClient struct { + grpc.ClientStream +} + +func (x *flowCombinationRpcEmptyStreamClient) Recv() (*EmptyProto, error) { + m := new(EmptyProto) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *flowCombinationClient) StreamEmptyRpc(ctx context.Context, opts ...grpc.CallOption) (FlowCombination_StreamEmptyRpcClient, error) { + stream, err := grpc.NewClientStream(ctx, &_FlowCombination_serviceDesc.Streams[1], c.cc, "/gengo.grpc.gateway.examples.examplepb.FlowCombination/StreamEmptyRpc", opts...) + if err != nil { + return nil, err + } + x := &flowCombinationStreamEmptyRpcClient{stream} + return x, nil +} + +type FlowCombination_StreamEmptyRpcClient interface { + Send(*EmptyProto) error + CloseAndRecv() (*EmptyProto, error) + grpc.ClientStream +} + +type flowCombinationStreamEmptyRpcClient struct { + grpc.ClientStream +} + +func (x *flowCombinationStreamEmptyRpcClient) Send(m *EmptyProto) error { + return x.ClientStream.SendMsg(m) +} + +func (x *flowCombinationStreamEmptyRpcClient) CloseAndRecv() (*EmptyProto, error) { + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + m := new(EmptyProto) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *flowCombinationClient) StreamEmptyStream(ctx context.Context, opts ...grpc.CallOption) (FlowCombination_StreamEmptyStreamClient, error) { + stream, err := grpc.NewClientStream(ctx, &_FlowCombination_serviceDesc.Streams[2], c.cc, "/gengo.grpc.gateway.examples.examplepb.FlowCombination/StreamEmptyStream", opts...) + if err != nil { + return nil, err + } + x := &flowCombinationStreamEmptyStreamClient{stream} + return x, nil +} + +type FlowCombination_StreamEmptyStreamClient interface { + Send(*EmptyProto) error + Recv() (*EmptyProto, error) + grpc.ClientStream +} + +type flowCombinationStreamEmptyStreamClient struct { + grpc.ClientStream +} + +func (x *flowCombinationStreamEmptyStreamClient) Send(m *EmptyProto) error { + return x.ClientStream.SendMsg(m) +} + +func (x *flowCombinationStreamEmptyStreamClient) Recv() (*EmptyProto, error) { + m := new(EmptyProto) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *flowCombinationClient) RpcBodyRpc(ctx context.Context, in *NonEmptyProto, opts ...grpc.CallOption) (*EmptyProto, error) { + out := new(EmptyProto) + err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.examplepb.FlowCombination/RpcBodyRpc", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *flowCombinationClient) RpcPathSingleNestedRpc(ctx context.Context, in *SingleNestedProto, opts ...grpc.CallOption) (*EmptyProto, error) { + out := new(EmptyProto) + err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.examplepb.FlowCombination/RpcPathSingleNestedRpc", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *flowCombinationClient) RpcPathNestedRpc(ctx context.Context, in *NestedProto, opts ...grpc.CallOption) (*EmptyProto, error) { + out := new(EmptyProto) + err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.examplepb.FlowCombination/RpcPathNestedRpc", in, out, c.cc, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *flowCombinationClient) RpcBodyStream(ctx context.Context, in *NonEmptyProto, opts ...grpc.CallOption) (FlowCombination_RpcBodyStreamClient, error) { + stream, err := grpc.NewClientStream(ctx, &_FlowCombination_serviceDesc.Streams[3], c.cc, "/gengo.grpc.gateway.examples.examplepb.FlowCombination/RpcBodyStream", opts...) + if err != nil { + return nil, err + } + x := &flowCombinationRpcBodyStreamClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type FlowCombination_RpcBodyStreamClient interface { + Recv() (*EmptyProto, error) + grpc.ClientStream +} + +type flowCombinationRpcBodyStreamClient struct { + grpc.ClientStream +} + +func (x *flowCombinationRpcBodyStreamClient) Recv() (*EmptyProto, error) { + m := new(EmptyProto) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *flowCombinationClient) RpcPathSingleNestedStream(ctx context.Context, in *SingleNestedProto, opts ...grpc.CallOption) (FlowCombination_RpcPathSingleNestedStreamClient, error) { + stream, err := grpc.NewClientStream(ctx, &_FlowCombination_serviceDesc.Streams[4], c.cc, "/gengo.grpc.gateway.examples.examplepb.FlowCombination/RpcPathSingleNestedStream", opts...) + if err != nil { + return nil, err + } + x := &flowCombinationRpcPathSingleNestedStreamClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type FlowCombination_RpcPathSingleNestedStreamClient interface { + Recv() (*EmptyProto, error) + grpc.ClientStream +} + +type flowCombinationRpcPathSingleNestedStreamClient struct { + grpc.ClientStream +} + +func (x *flowCombinationRpcPathSingleNestedStreamClient) Recv() (*EmptyProto, error) { + m := new(EmptyProto) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func (c *flowCombinationClient) RpcPathNestedStream(ctx context.Context, in *NestedProto, opts ...grpc.CallOption) (FlowCombination_RpcPathNestedStreamClient, error) { + stream, err := grpc.NewClientStream(ctx, &_FlowCombination_serviceDesc.Streams[5], c.cc, "/gengo.grpc.gateway.examples.examplepb.FlowCombination/RpcPathNestedStream", opts...) + if err != nil { + return nil, err + } + x := &flowCombinationRpcPathNestedStreamClient{stream} + if err := x.ClientStream.SendMsg(in); err != nil { + return nil, err + } + if err := x.ClientStream.CloseSend(); err != nil { + return nil, err + } + return x, nil +} + +type FlowCombination_RpcPathNestedStreamClient interface { + Recv() (*EmptyProto, error) + grpc.ClientStream +} + +type flowCombinationRpcPathNestedStreamClient struct { + grpc.ClientStream +} + +func (x *flowCombinationRpcPathNestedStreamClient) Recv() (*EmptyProto, error) { + m := new(EmptyProto) + if err := x.ClientStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +// Server API for FlowCombination service + +type FlowCombinationServer interface { + RpcEmptyRpc(context.Context, *EmptyProto) (*EmptyProto, error) + RpcEmptyStream(*EmptyProto, FlowCombination_RpcEmptyStreamServer) error + StreamEmptyRpc(FlowCombination_StreamEmptyRpcServer) error + StreamEmptyStream(FlowCombination_StreamEmptyStreamServer) error + RpcBodyRpc(context.Context, *NonEmptyProto) (*EmptyProto, error) + RpcPathSingleNestedRpc(context.Context, *SingleNestedProto) (*EmptyProto, error) + RpcPathNestedRpc(context.Context, *NestedProto) (*EmptyProto, error) + RpcBodyStream(*NonEmptyProto, FlowCombination_RpcBodyStreamServer) error + RpcPathSingleNestedStream(*SingleNestedProto, FlowCombination_RpcPathSingleNestedStreamServer) error + RpcPathNestedStream(*NestedProto, FlowCombination_RpcPathNestedStreamServer) error +} + +func RegisterFlowCombinationServer(s *grpc.Server, srv FlowCombinationServer) { + s.RegisterService(&_FlowCombination_serviceDesc, srv) +} + +func _FlowCombination_RpcEmptyRpc_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { + in := new(EmptyProto) + if err := codec.Unmarshal(buf, in); err != nil { + return nil, err + } + out, err := srv.(FlowCombinationServer).RpcEmptyRpc(ctx, in) + if err != nil { + return nil, err + } + return out, nil +} + +func _FlowCombination_RpcEmptyStream_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(EmptyProto) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(FlowCombinationServer).RpcEmptyStream(m, &flowCombinationRpcEmptyStreamServer{stream}) +} + +type FlowCombination_RpcEmptyStreamServer interface { + Send(*EmptyProto) error + grpc.ServerStream +} + +type flowCombinationRpcEmptyStreamServer struct { + grpc.ServerStream +} + +func (x *flowCombinationRpcEmptyStreamServer) Send(m *EmptyProto) error { + return x.ServerStream.SendMsg(m) +} + +func _FlowCombination_StreamEmptyRpc_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(FlowCombinationServer).StreamEmptyRpc(&flowCombinationStreamEmptyRpcServer{stream}) +} + +type FlowCombination_StreamEmptyRpcServer interface { + SendAndClose(*EmptyProto) error + Recv() (*EmptyProto, error) + grpc.ServerStream +} + +type flowCombinationStreamEmptyRpcServer struct { + grpc.ServerStream +} + +func (x *flowCombinationStreamEmptyRpcServer) SendAndClose(m *EmptyProto) error { + return x.ServerStream.SendMsg(m) +} + +func (x *flowCombinationStreamEmptyRpcServer) Recv() (*EmptyProto, error) { + m := new(EmptyProto) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _FlowCombination_StreamEmptyStream_Handler(srv interface{}, stream grpc.ServerStream) error { + return srv.(FlowCombinationServer).StreamEmptyStream(&flowCombinationStreamEmptyStreamServer{stream}) +} + +type FlowCombination_StreamEmptyStreamServer interface { + Send(*EmptyProto) error + Recv() (*EmptyProto, error) + grpc.ServerStream +} + +type flowCombinationStreamEmptyStreamServer struct { + grpc.ServerStream +} + +func (x *flowCombinationStreamEmptyStreamServer) Send(m *EmptyProto) error { + return x.ServerStream.SendMsg(m) +} + +func (x *flowCombinationStreamEmptyStreamServer) Recv() (*EmptyProto, error) { + m := new(EmptyProto) + if err := x.ServerStream.RecvMsg(m); err != nil { + return nil, err + } + return m, nil +} + +func _FlowCombination_RpcBodyRpc_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { + in := new(NonEmptyProto) + if err := codec.Unmarshal(buf, in); err != nil { + return nil, err + } + out, err := srv.(FlowCombinationServer).RpcBodyRpc(ctx, in) + if err != nil { + return nil, err + } + return out, nil +} + +func _FlowCombination_RpcPathSingleNestedRpc_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { + in := new(SingleNestedProto) + if err := codec.Unmarshal(buf, in); err != nil { + return nil, err + } + out, err := srv.(FlowCombinationServer).RpcPathSingleNestedRpc(ctx, in) + if err != nil { + return nil, err + } + return out, nil +} + +func _FlowCombination_RpcPathNestedRpc_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { + in := new(NestedProto) + if err := codec.Unmarshal(buf, in); err != nil { + return nil, err + } + out, err := srv.(FlowCombinationServer).RpcPathNestedRpc(ctx, in) + if err != nil { + return nil, err + } + return out, nil +} + +func _FlowCombination_RpcBodyStream_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(NonEmptyProto) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(FlowCombinationServer).RpcBodyStream(m, &flowCombinationRpcBodyStreamServer{stream}) +} + +type FlowCombination_RpcBodyStreamServer interface { + Send(*EmptyProto) error + grpc.ServerStream +} + +type flowCombinationRpcBodyStreamServer struct { + grpc.ServerStream +} + +func (x *flowCombinationRpcBodyStreamServer) Send(m *EmptyProto) error { + return x.ServerStream.SendMsg(m) +} + +func _FlowCombination_RpcPathSingleNestedStream_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(SingleNestedProto) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(FlowCombinationServer).RpcPathSingleNestedStream(m, &flowCombinationRpcPathSingleNestedStreamServer{stream}) +} + +type FlowCombination_RpcPathSingleNestedStreamServer interface { + Send(*EmptyProto) error + grpc.ServerStream +} + +type flowCombinationRpcPathSingleNestedStreamServer struct { + grpc.ServerStream +} + +func (x *flowCombinationRpcPathSingleNestedStreamServer) Send(m *EmptyProto) error { + return x.ServerStream.SendMsg(m) +} + +func _FlowCombination_RpcPathNestedStream_Handler(srv interface{}, stream grpc.ServerStream) error { + m := new(NestedProto) + if err := stream.RecvMsg(m); err != nil { + return err + } + return srv.(FlowCombinationServer).RpcPathNestedStream(m, &flowCombinationRpcPathNestedStreamServer{stream}) +} + +type FlowCombination_RpcPathNestedStreamServer interface { + Send(*EmptyProto) error + grpc.ServerStream +} + +type flowCombinationRpcPathNestedStreamServer struct { + grpc.ServerStream +} + +func (x *flowCombinationRpcPathNestedStreamServer) Send(m *EmptyProto) error { + return x.ServerStream.SendMsg(m) +} + +var _FlowCombination_serviceDesc = grpc.ServiceDesc{ + ServiceName: "gengo.grpc.gateway.examples.examplepb.FlowCombination", + HandlerType: (*FlowCombinationServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "RpcEmptyRpc", + Handler: _FlowCombination_RpcEmptyRpc_Handler, + }, + { + MethodName: "RpcBodyRpc", + Handler: _FlowCombination_RpcBodyRpc_Handler, + }, + { + MethodName: "RpcPathSingleNestedRpc", + Handler: _FlowCombination_RpcPathSingleNestedRpc_Handler, + }, + { + MethodName: "RpcPathNestedRpc", + Handler: _FlowCombination_RpcPathNestedRpc_Handler, + }, + }, + Streams: []grpc.StreamDesc{ + { + StreamName: "RpcEmptyStream", + Handler: _FlowCombination_RpcEmptyStream_Handler, + ServerStreams: true, + }, + { + StreamName: "StreamEmptyRpc", + Handler: _FlowCombination_StreamEmptyRpc_Handler, + ClientStreams: true, + }, + { + StreamName: "StreamEmptyStream", + Handler: _FlowCombination_StreamEmptyStream_Handler, + ServerStreams: true, + ClientStreams: true, + }, + { + StreamName: "RpcBodyStream", + Handler: _FlowCombination_RpcBodyStream_Handler, + ServerStreams: true, + }, + { + StreamName: "RpcPathSingleNestedStream", + Handler: _FlowCombination_RpcPathSingleNestedStream_Handler, + ServerStreams: true, + }, + { + StreamName: "RpcPathNestedStream", + Handler: _FlowCombination_RpcPathNestedStream_Handler, + ServerStreams: true, + }, + }, +} diff --git a/examples/examplepb/flow_combination.pb.gw.go b/examples/examplepb/flow_combination.pb.gw.go new file mode 100644 index 00000000000..da61a9d350e --- /dev/null +++ b/examples/examplepb/flow_combination.pb.gw.go @@ -0,0 +1,1211 @@ +// Code generated by protoc-gen-grpc-gateway +// source: examples/examplepb/flow_combination.proto +// DO NOT EDIT! + +/* +Package examplepb is a reverse proxy. + +It translates gRPC into RESTful JSON APIs. +*/ +package examplepb + +import ( + "encoding/json" + "io" + "net/http" + + "github.com/gengo/grpc-gateway/runtime" + "github.com/gengo/grpc-gateway/utilities" + "github.com/golang/glog" + "github.com/golang/protobuf/proto" + "golang.org/x/net/context" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" +) + +var _ codes.Code +var _ io.Reader +var _ = runtime.String +var _ = json.Marshal +var _ = utilities.PascalFromSnake + +func request_FlowCombination_RpcEmptyRpc_0(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { + var protoReq EmptyProto + + return client.RpcEmptyRpc(ctx, &protoReq) +} + +func request_FlowCombination_RpcEmptyStream_0(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcEmptyStreamClient, error) { + var protoReq EmptyProto + + return client.RpcEmptyStream(ctx, &protoReq) +} + +func request_FlowCombination_StreamEmptyRpc_0(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { + stream, err := client.StreamEmptyRpc(ctx) + if err != nil { + glog.Errorf("Failed to start streaming: %v", err) + return nil, err + } + dec := json.NewDecoder(req.Body) + for { + var protoReq EmptyProto + err = dec.Decode(&protoReq) + if err == io.EOF { + break + } + if err != nil { + glog.Errorf("Failed to decode request: %v", err) + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + if err = stream.Send(&protoReq); err != nil { + glog.Errorf("Failed to send request: %v", err) + return nil, err + } + } + + return stream.CloseAndRecv() + +} + +func request_FlowCombination_StreamEmptyStream_0(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_StreamEmptyStreamClient, error) { + stream, err := client.StreamEmptyStream(ctx) + if err != nil { + glog.Errorf("Failed to start streaming: %v", err) + return nil, err + } + dec := json.NewDecoder(req.Body) + for { + var protoReq EmptyProto + err = dec.Decode(&protoReq) + if err == io.EOF { + break + } + if err != nil { + glog.Errorf("Failed to decode request: %v", err) + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + if err = stream.Send(&protoReq); err != nil { + glog.Errorf("Failed to send request: %v", err) + return nil, err + } + } + + if err = stream.CloseSend(); err != nil { + glog.Errorf("Failed to terminate client stream: %v", err) + return nil, err + } + return stream, nil + +} + +func request_FlowCombination_RpcBodyRpc_0(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { + var protoReq NonEmptyProto + + if err := json.NewDecoder(req.Body).Decode(&protoReq); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcBodyRpc(ctx, &protoReq) +} + +func request_FlowCombination_RpcBodyRpc_1(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { + var protoReq NonEmptyProto + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["a"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a") + } + + protoReq.A, err = runtime.String(val) + + if err != nil { + return nil, err + } + + val, ok = pathParams["b"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "b") + } + + protoReq.B, err = runtime.String(val) + + if err != nil { + return nil, err + } + + val, ok = pathParams["c"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "c") + } + + protoReq.C, err = runtime.String(val) + + if err != nil { + return nil, err + } + + return client.RpcBodyRpc(ctx, &protoReq) +} + +var ( + filter_FlowCombination_RpcBodyRpc_2 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_FlowCombination_RpcBodyRpc_2(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { + var protoReq NonEmptyProto + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcBodyRpc_2); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcBodyRpc(ctx, &protoReq) +} + +func request_FlowCombination_RpcBodyRpc_3(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { + var protoReq NonEmptyProto + + if err := json.NewDecoder(req.Body).Decode(&protoReq.C); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["a"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a") + } + + protoReq.A, err = runtime.String(val) + + if err != nil { + return nil, err + } + + val, ok = pathParams["b"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "b") + } + + protoReq.B, err = runtime.String(val) + + if err != nil { + return nil, err + } + + return client.RpcBodyRpc(ctx, &protoReq) +} + +var ( + filter_FlowCombination_RpcBodyRpc_4 = &utilities.DoubleArray{Encoding: map[string]int{"c": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_FlowCombination_RpcBodyRpc_4(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { + var protoReq NonEmptyProto + + if err := json.NewDecoder(req.Body).Decode(&protoReq.C); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcBodyRpc_4); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcBodyRpc(ctx, &protoReq) +} + +var ( + filter_FlowCombination_RpcBodyRpc_5 = &utilities.DoubleArray{Encoding: map[string]int{"c": 0, "a": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} +) + +func request_FlowCombination_RpcBodyRpc_5(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { + var protoReq NonEmptyProto + + if err := json.NewDecoder(req.Body).Decode(&protoReq.C); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["a"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a") + } + + protoReq.A, err = runtime.String(val) + + if err != nil { + return nil, err + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcBodyRpc_5); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcBodyRpc(ctx, &protoReq) +} + +var ( + filter_FlowCombination_RpcBodyRpc_6 = &utilities.DoubleArray{Encoding: map[string]int{"a": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_FlowCombination_RpcBodyRpc_6(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { + var protoReq NonEmptyProto + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["a"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a") + } + + protoReq.A, err = runtime.String(val) + + if err != nil { + return nil, err + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcBodyRpc_6); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcBodyRpc(ctx, &protoReq) +} + +var ( + filter_FlowCombination_RpcPathSingleNestedRpc_0 = &utilities.DoubleArray{Encoding: map[string]int{"a": 0, "str": 1}, Base: []int{1, 1, 1, 0}, Check: []int{0, 1, 2, 3}} +) + +func request_FlowCombination_RpcPathSingleNestedRpc_0(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { + var protoReq SingleNestedProto + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["a.str"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) + + if err != nil { + return nil, err + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcPathSingleNestedRpc_0); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcPathSingleNestedRpc(ctx, &protoReq) +} + +var ( + filter_FlowCombination_RpcPathNestedRpc_0 = &utilities.DoubleArray{Encoding: map[string]int{"c": 0, "a": 1, "str": 2, "b": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 1, 3, 1, 2, 4, 5}} +) + +func request_FlowCombination_RpcPathNestedRpc_0(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { + var protoReq NestedProto + + if err := json.NewDecoder(req.Body).Decode(&protoReq.C); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["a.str"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) + + if err != nil { + return nil, err + } + + val, ok = pathParams["b"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "b") + } + + protoReq.B, err = runtime.String(val) + + if err != nil { + return nil, err + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcPathNestedRpc_0); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcPathNestedRpc(ctx, &protoReq) +} + +var ( + filter_FlowCombination_RpcPathNestedRpc_1 = &utilities.DoubleArray{Encoding: map[string]int{"a": 0, "str": 1}, Base: []int{1, 1, 1, 0}, Check: []int{0, 1, 2, 3}} +) + +func request_FlowCombination_RpcPathNestedRpc_1(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { + var protoReq NestedProto + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["a.str"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) + + if err != nil { + return nil, err + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcPathNestedRpc_1); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcPathNestedRpc(ctx, &protoReq) +} + +var ( + filter_FlowCombination_RpcPathNestedRpc_2 = &utilities.DoubleArray{Encoding: map[string]int{"c": 0, "a": 1, "str": 2}, Base: []int{1, 1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 3, 2, 4}} +) + +func request_FlowCombination_RpcPathNestedRpc_2(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (proto.Message, error) { + var protoReq NestedProto + + if err := json.NewDecoder(req.Body).Decode(&protoReq.C); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["a.str"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) + + if err != nil { + return nil, err + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcPathNestedRpc_2); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcPathNestedRpc(ctx, &protoReq) +} + +func request_FlowCombination_RpcBodyStream_0(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcBodyStreamClient, error) { + var protoReq NonEmptyProto + + if err := json.NewDecoder(req.Body).Decode(&protoReq); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcBodyStream(ctx, &protoReq) +} + +func request_FlowCombination_RpcBodyStream_1(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcBodyStreamClient, error) { + var protoReq NonEmptyProto + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["a"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a") + } + + protoReq.A, err = runtime.String(val) + + if err != nil { + return nil, err + } + + val, ok = pathParams["b"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "b") + } + + protoReq.B, err = runtime.String(val) + + if err != nil { + return nil, err + } + + val, ok = pathParams["c"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "c") + } + + protoReq.C, err = runtime.String(val) + + if err != nil { + return nil, err + } + + return client.RpcBodyStream(ctx, &protoReq) +} + +var ( + filter_FlowCombination_RpcBodyStream_2 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_FlowCombination_RpcBodyStream_2(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcBodyStreamClient, error) { + var protoReq NonEmptyProto + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcBodyStream_2); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcBodyStream(ctx, &protoReq) +} + +func request_FlowCombination_RpcBodyStream_3(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcBodyStreamClient, error) { + var protoReq NonEmptyProto + + if err := json.NewDecoder(req.Body).Decode(&protoReq.C); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["a"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a") + } + + protoReq.A, err = runtime.String(val) + + if err != nil { + return nil, err + } + + val, ok = pathParams["b"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "b") + } + + protoReq.B, err = runtime.String(val) + + if err != nil { + return nil, err + } + + return client.RpcBodyStream(ctx, &protoReq) +} + +var ( + filter_FlowCombination_RpcBodyStream_4 = &utilities.DoubleArray{Encoding: map[string]int{"c": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_FlowCombination_RpcBodyStream_4(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcBodyStreamClient, error) { + var protoReq NonEmptyProto + + if err := json.NewDecoder(req.Body).Decode(&protoReq.C); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcBodyStream_4); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcBodyStream(ctx, &protoReq) +} + +var ( + filter_FlowCombination_RpcBodyStream_5 = &utilities.DoubleArray{Encoding: map[string]int{"c": 0, "a": 1}, Base: []int{1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 2, 3}} +) + +func request_FlowCombination_RpcBodyStream_5(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcBodyStreamClient, error) { + var protoReq NonEmptyProto + + if err := json.NewDecoder(req.Body).Decode(&protoReq.C); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["a"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a") + } + + protoReq.A, err = runtime.String(val) + + if err != nil { + return nil, err + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcBodyStream_5); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcBodyStream(ctx, &protoReq) +} + +var ( + filter_FlowCombination_RpcBodyStream_6 = &utilities.DoubleArray{Encoding: map[string]int{"a": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_FlowCombination_RpcBodyStream_6(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcBodyStreamClient, error) { + var protoReq NonEmptyProto + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["a"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a") + } + + protoReq.A, err = runtime.String(val) + + if err != nil { + return nil, err + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcBodyStream_6); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcBodyStream(ctx, &protoReq) +} + +var ( + filter_FlowCombination_RpcPathSingleNestedStream_0 = &utilities.DoubleArray{Encoding: map[string]int{"a": 0, "str": 1}, Base: []int{1, 1, 1, 0}, Check: []int{0, 1, 2, 3}} +) + +func request_FlowCombination_RpcPathSingleNestedStream_0(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcPathSingleNestedStreamClient, error) { + var protoReq SingleNestedProto + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["a.str"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) + + if err != nil { + return nil, err + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcPathSingleNestedStream_0); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcPathSingleNestedStream(ctx, &protoReq) +} + +var ( + filter_FlowCombination_RpcPathNestedStream_0 = &utilities.DoubleArray{Encoding: map[string]int{"c": 0, "a": 1, "str": 2, "b": 3}, Base: []int{1, 1, 1, 2, 3, 0, 0, 0}, Check: []int{0, 1, 1, 3, 1, 2, 4, 5}} +) + +func request_FlowCombination_RpcPathNestedStream_0(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcPathNestedStreamClient, error) { + var protoReq NestedProto + + if err := json.NewDecoder(req.Body).Decode(&protoReq.C); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["a.str"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) + + if err != nil { + return nil, err + } + + val, ok = pathParams["b"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "b") + } + + protoReq.B, err = runtime.String(val) + + if err != nil { + return nil, err + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcPathNestedStream_0); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcPathNestedStream(ctx, &protoReq) +} + +var ( + filter_FlowCombination_RpcPathNestedStream_1 = &utilities.DoubleArray{Encoding: map[string]int{"a": 0, "str": 1}, Base: []int{1, 1, 1, 0}, Check: []int{0, 1, 2, 3}} +) + +func request_FlowCombination_RpcPathNestedStream_1(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcPathNestedStreamClient, error) { + var protoReq NestedProto + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["a.str"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) + + if err != nil { + return nil, err + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcPathNestedStream_1); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcPathNestedStream(ctx, &protoReq) +} + +var ( + filter_FlowCombination_RpcPathNestedStream_2 = &utilities.DoubleArray{Encoding: map[string]int{"c": 0, "a": 1, "str": 2}, Base: []int{1, 1, 1, 2, 0, 0}, Check: []int{0, 1, 1, 3, 2, 4}} +) + +func request_FlowCombination_RpcPathNestedStream_2(ctx context.Context, client FlowCombinationClient, req *http.Request, pathParams map[string]string) (FlowCombination_RpcPathNestedStreamClient, error) { + var protoReq NestedProto + + if err := json.NewDecoder(req.Body).Decode(&protoReq.C); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["a.str"] + if !ok { + return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "a.str") + } + + err = runtime.PopulateFieldFromPath(&protoReq, "a.str", val) + + if err != nil { + return nil, err + } + + if err := runtime.PopulateQueryParameters(&protoReq, req.URL.Query(), filter_FlowCombination_RpcPathNestedStream_2); err != nil { + return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) + } + + return client.RpcPathNestedStream(ctx, &protoReq) +} + +// RegisterFlowCombinationHandlerFromEndpoint is same as RegisterFlowCombinationHandler but +// automatically dials to "endpoint" and closes the connection when "ctx" gets done. +func RegisterFlowCombinationHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string) (err error) { + conn, err := grpc.Dial(endpoint) + if err != nil { + return err + } + defer func() { + if err != nil { + if cerr := conn.Close(); cerr != nil { + glog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + return + } + go func() { + <-ctx.Done() + if cerr := conn.Close(); cerr != nil { + glog.Errorf("Failed to close conn to %s: %v", endpoint, cerr) + } + }() + }() + + return RegisterFlowCombinationHandler(ctx, mux, conn) +} + +// RegisterFlowCombinationHandler registers the http handlers for service FlowCombination to "mux". +// The handlers forward requests to the grpc endpoint over "conn". +func RegisterFlowCombinationHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error { + client := NewFlowCombinationClient(conn) + + mux.Handle("POST", pattern_FlowCombination_RpcEmptyRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcEmptyRpc_0(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcEmptyRpc_0(ctx, w, req, resp) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcEmptyStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcEmptyStream_0(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcEmptyStream_0(ctx, w, req, func() (proto.Message, error) { return resp.Recv() }) + + }) + + mux.Handle("POST", pattern_FlowCombination_StreamEmptyRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_StreamEmptyRpc_0(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_StreamEmptyRpc_0(ctx, w, req, resp) + + }) + + mux.Handle("POST", pattern_FlowCombination_StreamEmptyStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_StreamEmptyStream_0(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_StreamEmptyStream_0(ctx, w, req, func() (proto.Message, error) { return resp.Recv() }) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcBodyRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcBodyRpc_0(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcBodyRpc_0(ctx, w, req, resp) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcBodyRpc_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcBodyRpc_1(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcBodyRpc_1(ctx, w, req, resp) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcBodyRpc_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcBodyRpc_2(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcBodyRpc_2(ctx, w, req, resp) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcBodyRpc_3, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcBodyRpc_3(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcBodyRpc_3(ctx, w, req, resp) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcBodyRpc_4, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcBodyRpc_4(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcBodyRpc_4(ctx, w, req, resp) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcBodyRpc_5, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcBodyRpc_5(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcBodyRpc_5(ctx, w, req, resp) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcBodyRpc_6, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcBodyRpc_6(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcBodyRpc_6(ctx, w, req, resp) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcPathSingleNestedRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcPathSingleNestedRpc_0(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcPathSingleNestedRpc_0(ctx, w, req, resp) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcPathNestedRpc_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcPathNestedRpc_0(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcPathNestedRpc_0(ctx, w, req, resp) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcPathNestedRpc_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcPathNestedRpc_1(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcPathNestedRpc_1(ctx, w, req, resp) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcPathNestedRpc_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcPathNestedRpc_2(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcPathNestedRpc_2(ctx, w, req, resp) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcBodyStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcBodyStream_0(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcBodyStream_0(ctx, w, req, func() (proto.Message, error) { return resp.Recv() }) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcBodyStream_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcBodyStream_1(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcBodyStream_1(ctx, w, req, func() (proto.Message, error) { return resp.Recv() }) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcBodyStream_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcBodyStream_2(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcBodyStream_2(ctx, w, req, func() (proto.Message, error) { return resp.Recv() }) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcBodyStream_3, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcBodyStream_3(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcBodyStream_3(ctx, w, req, func() (proto.Message, error) { return resp.Recv() }) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcBodyStream_4, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcBodyStream_4(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcBodyStream_4(ctx, w, req, func() (proto.Message, error) { return resp.Recv() }) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcBodyStream_5, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcBodyStream_5(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcBodyStream_5(ctx, w, req, func() (proto.Message, error) { return resp.Recv() }) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcBodyStream_6, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcBodyStream_6(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcBodyStream_6(ctx, w, req, func() (proto.Message, error) { return resp.Recv() }) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcPathSingleNestedStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcPathSingleNestedStream_0(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcPathSingleNestedStream_0(ctx, w, req, func() (proto.Message, error) { return resp.Recv() }) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcPathNestedStream_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcPathNestedStream_0(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcPathNestedStream_0(ctx, w, req, func() (proto.Message, error) { return resp.Recv() }) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcPathNestedStream_1, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcPathNestedStream_1(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcPathNestedStream_1(ctx, w, req, func() (proto.Message, error) { return resp.Recv() }) + + }) + + mux.Handle("POST", pattern_FlowCombination_RpcPathNestedStream_2, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + resp, err := request_FlowCombination_RpcPathNestedStream_2(runtime.AnnotateContext(ctx, req), client, req, pathParams) + if err != nil { + runtime.HTTPError(ctx, w, err) + return + } + + forward_FlowCombination_RpcPathNestedStream_2(ctx, w, req, func() (proto.Message, error) { return resp.Recv() }) + + }) + + return nil +} + +var ( + pattern_FlowCombination_RpcEmptyRpc_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 0}, []string{"rpc", "empty"}, "")) + + pattern_FlowCombination_RpcEmptyStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"rpc", "empty", "stream"}, "")) + + pattern_FlowCombination_StreamEmptyRpc_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"stream", "empty", "rpc"}, "")) + + pattern_FlowCombination_StreamEmptyStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 0}, []string{"stream", "empty"}, "")) + + pattern_FlowCombination_RpcBodyRpc_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 0}, []string{"rpc", "body"}, "")) + + pattern_FlowCombination_RpcBodyRpc_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 2, 0}, []string{"rpc", "path", "a", "b", "c"}, "")) + + pattern_FlowCombination_RpcBodyRpc_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 0}, []string{"rpc", "query"}, "")) + + pattern_FlowCombination_RpcBodyRpc_3 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 2, 0}, []string{"rpc", "body", "path", "a", "b"}, "")) + + pattern_FlowCombination_RpcBodyRpc_4 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 0}, []string{"rpc", "body", "query"}, "")) + + pattern_FlowCombination_RpcBodyRpc_5 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 2, 0}, []string{"rpc", "body", "path", "a", "query"}, "")) + + pattern_FlowCombination_RpcBodyRpc_6 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 2, 0}, []string{"rpc", "path", "a", "query"}, "")) + + pattern_FlowCombination_RpcPathSingleNestedRpc_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 0}, []string{"rpc", "path-nested", "a.str"}, "")) + + pattern_FlowCombination_RpcPathNestedRpc_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 1, 0, 4, 1, 5, 3, 2, 0}, []string{"rpc", "path-nested", "a.str", "b"}, "")) + + pattern_FlowCombination_RpcPathNestedRpc_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 0}, []string{"rpc", "path-nested", "a.str"}, "")) + + pattern_FlowCombination_RpcPathNestedRpc_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 0}, []string{"rpc", "path-nested", "a.str"}, "")) + + pattern_FlowCombination_RpcBodyStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"rpc", "body", "stream"}, "")) + + pattern_FlowCombination_RpcBodyStream_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"rpc", "path", "a", "b", "c", "stream"}, "")) + + pattern_FlowCombination_RpcBodyStream_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"rpc", "query", "stream"}, "")) + + pattern_FlowCombination_RpcBodyStream_3 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 1, 0, 4, 1, 5, 4, 2, 5}, []string{"rpc", "body", "path", "a", "b", "stream"}, "")) + + pattern_FlowCombination_RpcBodyStream_4 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"rpc", "body", "query", "stream"}, "")) + + pattern_FlowCombination_RpcBodyStream_5 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 1, 0, 4, 1, 5, 3, 2, 4, 2, 5}, []string{"rpc", "body", "path", "a", "query", "stream"}, "")) + + pattern_FlowCombination_RpcBodyStream_6 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3, 2, 4}, []string{"rpc", "path", "a", "query", "stream"}, "")) + + pattern_FlowCombination_RpcPathSingleNestedStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"rpc", "path-nested", "a.str", "stream"}, "")) + + pattern_FlowCombination_RpcPathNestedStream_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 1, 0, 4, 1, 5, 3, 2, 4}, []string{"rpc", "path-nested", "a.str", "b", "stream"}, "")) + + pattern_FlowCombination_RpcPathNestedStream_1 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"rpc", "path-nested", "a.str", "stream"}, "")) + + pattern_FlowCombination_RpcPathNestedStream_2 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 1, 0, 4, 1, 5, 2, 2, 3}, []string{"rpc", "path-nested", "a.str", "stream"}, "")) +) + +var ( + forward_FlowCombination_RpcEmptyRpc_0 = runtime.ForwardResponseMessage + + forward_FlowCombination_RpcEmptyStream_0 = runtime.ForwardResponseStream + + forward_FlowCombination_StreamEmptyRpc_0 = runtime.ForwardResponseMessage + + forward_FlowCombination_StreamEmptyStream_0 = runtime.ForwardResponseStream + + forward_FlowCombination_RpcBodyRpc_0 = runtime.ForwardResponseMessage + + forward_FlowCombination_RpcBodyRpc_1 = runtime.ForwardResponseMessage + + forward_FlowCombination_RpcBodyRpc_2 = runtime.ForwardResponseMessage + + forward_FlowCombination_RpcBodyRpc_3 = runtime.ForwardResponseMessage + + forward_FlowCombination_RpcBodyRpc_4 = runtime.ForwardResponseMessage + + forward_FlowCombination_RpcBodyRpc_5 = runtime.ForwardResponseMessage + + forward_FlowCombination_RpcBodyRpc_6 = runtime.ForwardResponseMessage + + forward_FlowCombination_RpcPathSingleNestedRpc_0 = runtime.ForwardResponseMessage + + forward_FlowCombination_RpcPathNestedRpc_0 = runtime.ForwardResponseMessage + + forward_FlowCombination_RpcPathNestedRpc_1 = runtime.ForwardResponseMessage + + forward_FlowCombination_RpcPathNestedRpc_2 = runtime.ForwardResponseMessage + + forward_FlowCombination_RpcBodyStream_0 = runtime.ForwardResponseStream + + forward_FlowCombination_RpcBodyStream_1 = runtime.ForwardResponseStream + + forward_FlowCombination_RpcBodyStream_2 = runtime.ForwardResponseStream + + forward_FlowCombination_RpcBodyStream_3 = runtime.ForwardResponseStream + + forward_FlowCombination_RpcBodyStream_4 = runtime.ForwardResponseStream + + forward_FlowCombination_RpcBodyStream_5 = runtime.ForwardResponseStream + + forward_FlowCombination_RpcBodyStream_6 = runtime.ForwardResponseStream + + forward_FlowCombination_RpcPathSingleNestedStream_0 = runtime.ForwardResponseStream + + forward_FlowCombination_RpcPathNestedStream_0 = runtime.ForwardResponseStream + + forward_FlowCombination_RpcPathNestedStream_1 = runtime.ForwardResponseStream + + forward_FlowCombination_RpcPathNestedStream_2 = runtime.ForwardResponseStream +) diff --git a/examples/examplepb/flow_combination.proto b/examples/examplepb/flow_combination.proto new file mode 100644 index 00000000000..9c321fe0fba --- /dev/null +++ b/examples/examplepb/flow_combination.proto @@ -0,0 +1,168 @@ +syntax = "proto3"; +option go_package = "examplepb"; +package gengo.grpc.gateway.examples.examplepb; + +import "google/api/annotations.proto"; + +message EmptyProto {} + +message NonEmptyProto { + string a = 1; + string b = 2; + string c = 3; +} + +message UnaryProto { + string str = 1; +} + +message NestedProto { + UnaryProto a = 1; + string b = 2; + string c = 3; +} + +message SingleNestedProto { + UnaryProto a = 1; +} + +service FlowCombination { + rpc RpcEmptyRpc(EmptyProto) returns (EmptyProto) { + option (google.api.http) = { + post: "/rpc/empty/rpc" + }; + } + rpc RpcEmptyStream(EmptyProto) returns (stream EmptyProto) { + option (google.api.http) = { + post: "/rpc/empty/stream" + }; + } + rpc StreamEmptyRpc(stream EmptyProto) returns (EmptyProto) { + option (google.api.http) = { + post: "/stream/empty/rpc" + }; + } + rpc StreamEmptyStream(stream EmptyProto) returns (stream EmptyProto) { + option (google.api.http) = { + post: "/stream/empty/stream" + }; + } + + rpc RpcBodyRpc(NonEmptyProto) returns (EmptyProto) { + option (google.api.http) = { + // w/ body; w/o path; w/o query + post: "/rpc/body/rpc" + body: "*" + + // w/o body; w/ path; w/o query + additional_bindings { + post: "/rpc/path/{a}/{b}/{c}/rpc" + } + // w/o body; w/o path; w/ query + additional_bindings { + post: "/rpc/query/rpc" + } + // w/ body; w/ path; w/o query + additional_bindings { + post: "/rpc/body/path/{a}/{b}/rpc" + body: "c" + } + // w/ body; w/o path; w/ query + additional_bindings { + post: "/rpc/body/query/rpc" + body: "c" + } + // w/ body; w/ path; w/ query + additional_bindings { + post: "/rpc/body/path/{a}/query/rpc" + body: "c" + } + // w/o body; w/ path; w/ query + additional_bindings { + post: "/rpc/path/{a}/query/rpc" + } + }; + } + rpc RpcPathSingleNestedRpc(SingleNestedProto) returns (EmptyProto) { + option (google.api.http) = { + // w/o body; w/ path (IsNestedProto3); w/o query + post: "/rpc/path-nested/{a.str}/rpc" + }; + } + rpc RpcPathNestedRpc(NestedProto) returns (EmptyProto) { + option (google.api.http) = { + // w/ body; w/ path (IsNestedProto3); w/o query + post: "/rpc/path-nested/{a.str}/{b}/rpc" + body: "c" + + // w/o body; w/ path (IsNestedProto3); w/ query + additional_bindings { + post: "/rpc/path-nested/{a.str}/rpc" + } + // w/ body; w/ path (IsNestedProto3); w/ query + additional_bindings { + post: "/rpc/path-nested/{a.str}/rpc" + body: "c" + } + }; + } + + rpc RpcBodyStream(NonEmptyProto) returns (stream EmptyProto) { + option (google.api.http) = { + // w/ body; w/o path; w/o query + post: "/rpc/body/stream" + body: "*" + + // w/o body; w/ path; w/o query + additional_bindings { + post: "/rpc/path/{a}/{b}/{c}/stream" + } + // w/o body; w/o path; w/ query + additional_bindings { + post: "/rpc/query/stream" + } + // w/ body; w/ path; w/o query + additional_bindings { + post: "/rpc/body/path/{a}/{b}/stream" + body: "c" + } + // w/ body; w/o path; w/ query + additional_bindings { + post: "/rpc/body/query/stream" + body: "c" + } + // w/ body; w/ path; w/ query + additional_bindings { + post: "/rpc/body/path/{a}/query/stream" + body: "c" + } + // w/o body; w/ path; w/ query + additional_bindings { + post: "/rpc/path/{a}/query/stream" + } + }; + } + rpc RpcPathSingleNestedStream(SingleNestedProto) returns (stream EmptyProto) { + option (google.api.http) = { + // w/o body; w/ path (IsNestedProto3); w/o query + post: "/rpc/path-nested/{a.str}/stream" + }; + } + rpc RpcPathNestedStream(NestedProto) returns (stream EmptyProto) { + option (google.api.http) = { + // w/ body; w/ path (IsNestedProto3); w/o query + post: "/rpc/path-nested/{a.str}/{b}/stream" + body: "c" + + // w/o body; w/ path (IsNestedProto3); w/ query + additional_bindings { + post: "/rpc/path-nested/{a.str}/stream" + } + // w/ body; w/ path (IsNestedProto3); w/ query + additional_bindings { + post: "/rpc/path-nested/{a.str}/stream" + body: "c" + } + }; + } +} diff --git a/examples/main.go b/examples/main.go index 0d4b6f86523..facfd9168a9 100644 --- a/examples/main.go +++ b/examples/main.go @@ -13,6 +13,7 @@ import ( var ( echoEndpoint = flag.String("echo_endpoint", "localhost:9090", "endpoint of EchoService") abeEndpoint = flag.String("more_endpoint", "localhost:9090", "endpoint of ABitOfEverythingService") + flowEndpoint = flag.String("flow_endpoint", "localhost:9090", "endpoint of FlowCombination") ) func Run() error { @@ -29,6 +30,10 @@ func Run() error { if err != nil { return err } + err = examplepb.RegisterFlowCombinationHandlerFromEndpoint(ctx, mux, *flowEndpoint) + if err != nil { + return err + } http.ListenAndServe(":8080", mux) return nil diff --git a/examples/server/a_bit_of_everything.go b/examples/server/a_bit_of_everything.go new file mode 100644 index 00000000000..49d52223bcd --- /dev/null +++ b/examples/server/a_bit_of_everything.go @@ -0,0 +1,147 @@ +package main + +import ( + "fmt" + "io" + "sync" + + examples "github.com/gengo/grpc-gateway/examples/examplepb" + sub "github.com/gengo/grpc-gateway/examples/sub" + "github.com/golang/glog" + "github.com/rogpeppe/fastuuid" + "golang.org/x/net/context" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" +) + +// Implements of ABitOfEverythingServiceServer + +var uuidgen = fastuuid.MustNewGenerator() + +type _ABitOfEverythingServer struct { + v map[string]*examples.ABitOfEverything + m sync.Mutex +} + +func newABitOfEverythingServer() examples.ABitOfEverythingServiceServer { + return &_ABitOfEverythingServer{ + v: make(map[string]*examples.ABitOfEverything), + } +} + +func (s *_ABitOfEverythingServer) Create(ctx context.Context, msg *examples.ABitOfEverything) (*examples.ABitOfEverything, error) { + s.m.Lock() + defer s.m.Unlock() + + glog.Info(msg) + var uuid string + for { + uuid = fmt.Sprintf("%x", uuidgen.Next()) + if _, ok := s.v[uuid]; !ok { + break + } + } + s.v[uuid] = msg + s.v[uuid].Uuid = uuid + glog.Infof("%v", s.v[uuid]) + return s.v[uuid], nil +} + +func (s *_ABitOfEverythingServer) CreateBody(ctx context.Context, msg *examples.ABitOfEverything) (*examples.ABitOfEverything, error) { + return s.Create(ctx, msg) +} + +func (s *_ABitOfEverythingServer) BulkCreate(stream examples.ABitOfEverythingService_BulkCreateServer) error { + ctx := stream.Context() + for { + msg, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + return err + } + glog.Error(msg) + if _, err = s.Create(ctx, msg); err != nil { + return err + } + } + return stream.SendAndClose(new(examples.EmptyMessage)) +} + +func (s *_ABitOfEverythingServer) Lookup(ctx context.Context, msg *examples.IdMessage) (*examples.ABitOfEverything, error) { + s.m.Lock() + defer s.m.Unlock() + + glog.Info(msg) + if a, ok := s.v[msg.Uuid]; ok { + return a, nil + } + return nil, grpc.Errorf(codes.NotFound, "not found") +} + +func (s *_ABitOfEverythingServer) List(_ *examples.EmptyMessage, stream examples.ABitOfEverythingService_ListServer) error { + s.m.Lock() + defer s.m.Unlock() + for _, msg := range s.v { + if err := stream.Send(msg); err != nil { + return err + } + } + return nil +} + +func (s *_ABitOfEverythingServer) Update(ctx context.Context, msg *examples.ABitOfEverything) (*examples.EmptyMessage, error) { + s.m.Lock() + defer s.m.Unlock() + + glog.Info(msg) + if _, ok := s.v[msg.Uuid]; ok { + s.v[msg.Uuid] = msg + } else { + return nil, grpc.Errorf(codes.NotFound, "not found") + } + return new(examples.EmptyMessage), nil +} + +func (s *_ABitOfEverythingServer) Delete(ctx context.Context, msg *examples.IdMessage) (*examples.EmptyMessage, error) { + s.m.Lock() + defer s.m.Unlock() + + glog.Info(msg) + if _, ok := s.v[msg.Uuid]; ok { + delete(s.v, msg.Uuid) + } else { + return nil, grpc.Errorf(codes.NotFound, "not found") + } + return new(examples.EmptyMessage), nil +} + +func (s *_ABitOfEverythingServer) Echo(ctx context.Context, msg *sub.StringMessage) (*sub.StringMessage, error) { + s.m.Lock() + defer s.m.Unlock() + + glog.Info(msg) + return msg, nil +} + +func (s *_ABitOfEverythingServer) BulkEcho(stream examples.ABitOfEverythingService_BulkEchoServer) error { + var msgs []*sub.StringMessage + for { + msg, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + return err + } + msgs = append(msgs, msg) + } + for _, msg := range msgs { + glog.Info(msg) + if err := stream.Send(msg); err != nil { + return err + } + } + return nil +} diff --git a/examples/server/echo.go b/examples/server/echo.go new file mode 100644 index 00000000000..040a9e5da68 --- /dev/null +++ b/examples/server/echo.go @@ -0,0 +1,25 @@ +package main + +import ( + examples "github.com/gengo/grpc-gateway/examples/examplepb" + "github.com/golang/glog" + "golang.org/x/net/context" +) + +// Implements of EchoServiceServer + +type echoServer struct{} + +func newEchoServer() examples.EchoServiceServer { + return new(echoServer) +} + +func (s *echoServer) Echo(ctx context.Context, msg *examples.SimpleMessage) (*examples.SimpleMessage, error) { + glog.Info(msg) + return msg, nil +} + +func (s *echoServer) EchoBody(ctx context.Context, msg *examples.SimpleMessage) (*examples.SimpleMessage, error) { + glog.Info(msg) + return msg, nil +} diff --git a/examples/server/flow_combination.go b/examples/server/flow_combination.go new file mode 100644 index 00000000000..b6aa0d92f01 --- /dev/null +++ b/examples/server/flow_combination.go @@ -0,0 +1,72 @@ +package main + +import ( + "io" + + examples "github.com/gengo/grpc-gateway/examples/examplepb" + "golang.org/x/net/context" +) + +type flowCombinationServer struct{} + +func newFlowCombinationServer() examples.FlowCombinationServer { + return &flowCombinationServer{} +} + +func (s flowCombinationServer) RpcEmptyRpc(ctx context.Context, req *examples.EmptyProto) (*examples.EmptyProto, error) { + return req, nil +} + +func (s flowCombinationServer) RpcEmptyStream(req *examples.EmptyProto, stream examples.FlowCombination_RpcEmptyStreamServer) error { + return stream.Send(req) +} + +func (s flowCombinationServer) StreamEmptyRpc(stream examples.FlowCombination_StreamEmptyRpcServer) error { + for { + _, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + return err + } + } + return stream.SendAndClose(new(examples.EmptyProto)) +} + +func (s flowCombinationServer) StreamEmptyStream(stream examples.FlowCombination_StreamEmptyStreamServer) error { + for { + _, err := stream.Recv() + if err == io.EOF { + break + } + if err != nil { + return err + } + } + return stream.Send(new(examples.EmptyProto)) +} + +func (s flowCombinationServer) RpcBodyRpc(ctx context.Context, req *examples.NonEmptyProto) (*examples.EmptyProto, error) { + return new(examples.EmptyProto), nil +} + +func (s flowCombinationServer) RpcPathSingleNestedRpc(ctx context.Context, req *examples.SingleNestedProto) (*examples.EmptyProto, error) { + return new(examples.EmptyProto), nil +} + +func (s flowCombinationServer) RpcPathNestedRpc(ctx context.Context, req *examples.NestedProto) (*examples.EmptyProto, error) { + return new(examples.EmptyProto), nil +} + +func (s flowCombinationServer) RpcBodyStream(req *examples.NonEmptyProto, stream examples.FlowCombination_RpcBodyStreamServer) error { + return stream.Send(new(examples.EmptyProto)) +} + +func (s flowCombinationServer) RpcPathSingleNestedStream(req *examples.SingleNestedProto, stream examples.FlowCombination_RpcPathSingleNestedStreamServer) error { + return stream.Send(new(examples.EmptyProto)) +} + +func (s flowCombinationServer) RpcPathNestedStream(req *examples.NestedProto, stream examples.FlowCombination_RpcPathNestedStreamServer) error { + return stream.Send(new(examples.EmptyProto)) +} diff --git a/examples/server/main.go b/examples/server/main.go index a48ef60dcaa..c08115aad55 100644 --- a/examples/server/main.go +++ b/examples/server/main.go @@ -2,170 +2,13 @@ package main import ( "flag" - "fmt" - "io" "net" - "sync" examples "github.com/gengo/grpc-gateway/examples/examplepb" - sub "github.com/gengo/grpc-gateway/examples/sub" "github.com/golang/glog" - "github.com/rogpeppe/fastuuid" - "golang.org/x/net/context" "google.golang.org/grpc" - "google.golang.org/grpc/codes" ) -// Implements of EchoServiceServer - -type echoServer struct{} - -func newEchoServer() examples.EchoServiceServer { - return new(echoServer) -} - -func (s *echoServer) Echo(ctx context.Context, msg *examples.SimpleMessage) (*examples.SimpleMessage, error) { - glog.Info(msg) - return msg, nil -} - -func (s *echoServer) EchoBody(ctx context.Context, msg *examples.SimpleMessage) (*examples.SimpleMessage, error) { - glog.Info(msg) - return msg, nil -} - -// Implements of ABitOfEverythingServiceServer - -var uuidgen = fastuuid.MustNewGenerator() - -type _ABitOfEverythingServer struct { - v map[string]*examples.ABitOfEverything - m sync.Mutex -} - -func newABitOfEverythingServer() examples.ABitOfEverythingServiceServer { - return &_ABitOfEverythingServer{ - v: make(map[string]*examples.ABitOfEverything), - } -} - -func (s *_ABitOfEverythingServer) Create(ctx context.Context, msg *examples.ABitOfEverything) (*examples.ABitOfEverything, error) { - s.m.Lock() - defer s.m.Unlock() - - glog.Info(msg) - var uuid string - for { - uuid = fmt.Sprintf("%x", uuidgen.Next()) - if _, ok := s.v[uuid]; !ok { - break - } - } - s.v[uuid] = msg - s.v[uuid].Uuid = uuid - glog.Infof("%v", s.v[uuid]) - return s.v[uuid], nil -} - -func (s *_ABitOfEverythingServer) CreateBody(ctx context.Context, msg *examples.ABitOfEverything) (*examples.ABitOfEverything, error) { - return s.Create(ctx, msg) -} - -func (s *_ABitOfEverythingServer) BulkCreate(stream examples.ABitOfEverythingService_BulkCreateServer) error { - ctx := stream.Context() - for { - msg, err := stream.Recv() - if err == io.EOF { - break - } - if err != nil { - return err - } - glog.Error(msg) - if _, err = s.Create(ctx, msg); err != nil { - return err - } - } - return stream.SendAndClose(new(examples.EmptyMessage)) -} - -func (s *_ABitOfEverythingServer) Lookup(ctx context.Context, msg *examples.IdMessage) (*examples.ABitOfEverything, error) { - s.m.Lock() - defer s.m.Unlock() - - glog.Info(msg) - if a, ok := s.v[msg.Uuid]; ok { - return a, nil - } - return nil, grpc.Errorf(codes.NotFound, "not found") -} - -func (s *_ABitOfEverythingServer) List(_ *examples.EmptyMessage, stream examples.ABitOfEverythingService_ListServer) error { - s.m.Lock() - defer s.m.Unlock() - for _, msg := range s.v { - if err := stream.Send(msg); err != nil { - return err - } - } - return nil -} - -func (s *_ABitOfEverythingServer) Update(ctx context.Context, msg *examples.ABitOfEverything) (*examples.EmptyMessage, error) { - s.m.Lock() - defer s.m.Unlock() - - glog.Info(msg) - if _, ok := s.v[msg.Uuid]; ok { - s.v[msg.Uuid] = msg - } else { - return nil, grpc.Errorf(codes.NotFound, "not found") - } - return new(examples.EmptyMessage), nil -} - -func (s *_ABitOfEverythingServer) Delete(ctx context.Context, msg *examples.IdMessage) (*examples.EmptyMessage, error) { - s.m.Lock() - defer s.m.Unlock() - - glog.Info(msg) - if _, ok := s.v[msg.Uuid]; ok { - delete(s.v, msg.Uuid) - } else { - return nil, grpc.Errorf(codes.NotFound, "not found") - } - return new(examples.EmptyMessage), nil -} - -func (s *_ABitOfEverythingServer) Echo(ctx context.Context, msg *sub.StringMessage) (*sub.StringMessage, error) { - s.m.Lock() - defer s.m.Unlock() - - glog.Info(msg) - return msg, nil -} - -func (s *_ABitOfEverythingServer) BulkEcho(stream examples.ABitOfEverythingService_BulkEchoServer) error { - var msgs []*sub.StringMessage - for { - msg, err := stream.Recv() - if err == io.EOF { - break - } - if err != nil { - return err - } - msgs = append(msgs, msg) - } - for _, msg := range msgs { - glog.Info(msg) - if err := stream.Send(msg); err != nil { - return err - } - } - return nil -} - func Run() error { l, err := net.Listen("tcp", ":9090") if err != nil { @@ -174,6 +17,7 @@ func Run() error { s := grpc.NewServer() examples.RegisterEchoServiceServer(s, newEchoServer()) examples.RegisterABitOfEverythingServiceServer(s, newABitOfEverythingServer()) + examples.RegisterFlowCombinationServer(s, newFlowCombinationServer()) s.Serve(l) return nil } diff --git a/protoc-gen-grpc-gateway/gengateway/template.go b/protoc-gen-grpc-gateway/gengateway/template.go index e313a0f667c..66ed99a3153 100644 --- a/protoc-gen-grpc-gateway/gengateway/template.go +++ b/protoc-gen-grpc-gateway/gengateway/template.go @@ -6,8 +6,8 @@ import ( "strings" "text/template" - "github.com/gengo/grpc-gateway/utilities" "github.com/gengo/grpc-gateway/protoc-gen-grpc-gateway/descriptor" + "github.com/gengo/grpc-gateway/utilities" "github.com/golang/glog" ) @@ -129,7 +129,7 @@ var _ = utilities.PascalFromSnake {{if .Method.GetServerStreaming}} func request_{{.Method.Service.GetName}}_{{.Method.GetName}}_{{.Index}}(ctx context.Context, client {{.Method.Service.GetName}}Client, req *http.Request, pathParams map[string]string) ({{.Method.Service.GetName}}_{{.Method.GetName}}Client, error) {{else}} -func request_{{.Method.Service.GetName}}_{{.Method.GetName}}_{{.Index}}(ctx context.Context, client {{.Method.Service.GetName}}Client, req *http.Request, pathParams map[string]string) (msg proto.Message, err error) +func request_{{.Method.Service.GetName}}_{{.Method.GetName}}_{{.Index}}(ctx context.Context, client {{.Method.Service.GetName}}Client, req *http.Request, pathParams map[string]string) (proto.Message, error) {{end}}`, "\n", "", -1))) _ = template.Must(handlerTemplate.New("client-streaming-request-func").Parse(` @@ -176,13 +176,17 @@ var ( {{template "request-func-signature" .}} { var protoReq {{.Method.RequestType.GoType .Method.Service.File.GoPkg.Path}} {{if .Body}} - if err = json.NewDecoder(req.Body).Decode(&{{.Body.RHS "protoReq"}}); err != nil { + if err := json.NewDecoder(req.Body).Decode(&{{.Body.RHS "protoReq"}}); err != nil { return nil, grpc.Errorf(codes.InvalidArgument, "%v", err) } {{end}} {{if .PathParams}} - var val string - var ok bool + var ( + val string + ok bool + err error + _ = err + ) {{range $param := .PathParams}} val, ok = pathParams[{{$param | printf "%q"}}] if !ok { diff --git a/protoc-gen-grpc-gateway/gengateway/template_test.go b/protoc-gen-grpc-gateway/gengateway/template_test.go index f52287f16cc..77e8d50fbb3 100644 --- a/protoc-gen-grpc-gateway/gengateway/template_test.go +++ b/protoc-gen-grpc-gateway/gengateway/template_test.go @@ -133,7 +133,7 @@ func TestApplyTemplateRequestWithoutClientStreaming(t *testing.T) { }{ { serverStreaming: false, - sigWant: `func request_ExampleService_Echo_0(ctx context.Context, client ExampleServiceClient, req *http.Request, pathParams map[string]string) (msg proto.Message, err error) {`, + sigWant: `func request_ExampleService_Echo_0(ctx context.Context, client ExampleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, error) {`, }, { serverStreaming: true, @@ -294,7 +294,7 @@ func TestApplyTemplateRequestWithClientStreaming(t *testing.T) { }{ { serverStreaming: false, - sigWant: `func request_ExampleService_Echo_0(ctx context.Context, client ExampleServiceClient, req *http.Request, pathParams map[string]string) (msg proto.Message, err error) {`, + sigWant: `func request_ExampleService_Echo_0(ctx context.Context, client ExampleServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, error) {`, }, { serverStreaming: true,