From dfaf6414f36ebce659d1dfda6272386b5aa9febc Mon Sep 17 00:00:00 2001 From: Travis Cline Date: Thu, 13 Aug 2015 19:26:28 -0400 Subject: [PATCH] fix examples to work with go1.5 --- Makefile | 4 +- .../{ => examplepb}/a_bit_of_everything.pb.go | 53 +++++++++---------- .../a_bit_of_everything.pb.gw.go | 44 +++++++++++++-- .../{ => examplepb}/a_bit_of_everything.proto | 4 +- examples/{ => examplepb}/echo_service.pb.go | 29 +++++----- .../{ => examplepb}/echo_service.pb.gw.go | 10 ++-- examples/{ => examplepb}/echo_service.proto | 4 +- examples/integration_test.go | 6 +-- examples/main.go | 5 +- examples/server/main.go | 2 +- examples/sub/message.pb.go | 3 -- third_party/googleapis/google/api/http.pb.go | 3 -- 12 files changed, 97 insertions(+), 70 deletions(-) rename examples/{ => examplepb}/a_bit_of_everything.pb.go (89%) rename examples/{ => examplepb}/a_bit_of_everything.pb.gw.go (99%) rename examples/{ => examplepb}/a_bit_of_everything.proto (97%) rename examples/{ => examplepb}/echo_service.pb.go (77%) rename examples/{ => examplepb}/echo_service.pb.gw.go (97%) rename examples/{ => examplepb}/echo_service.proto (82%) diff --git a/Makefile b/Makefile index b3f70c5e631..92da377f8ea 100644 --- a/Makefile +++ b/Makefile @@ -21,8 +21,8 @@ OPTIONS_PROTO=$(GOOGLEAPIS_DIR)/google/api/annotations.proto $(GOOGLEAPIS_DIR)/g 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/echo_service.proto \ - examples/a_bit_of_everything.proto +EXAMPLES=examples/examplepb/echo_service.proto \ + examples/examplepb/a_bit_of_everything.proto EXAMPLE_SVCSRCS=$(EXAMPLES:.proto=.pb.go) EXAMPLE_GWSRCS=$(EXAMPLES:.proto=.pb.gw.go) EXAMPLE_DEPS=examples/sub/message.proto diff --git a/examples/a_bit_of_everything.pb.go b/examples/examplepb/a_bit_of_everything.pb.go similarity index 89% rename from examples/a_bit_of_everything.pb.go rename to examples/examplepb/a_bit_of_everything.pb.go index f4b1da3c0f6..5c9f422c36e 100644 --- a/examples/a_bit_of_everything.pb.go +++ b/examples/examplepb/a_bit_of_everything.pb.go @@ -1,12 +1,12 @@ // Code generated by protoc-gen-go. -// source: examples/a_bit_of_everything.proto +// source: examples/examplepb/a_bit_of_everything.proto // DO NOT EDIT! -package main +package examplepb import proto "github.com/golang/protobuf/proto" -// discarding unused import google_api1 "google/api/annotations.pb" +// discarding unused import google_api1 "google/api" import gengo_grpc_gateway_examples_sub "github.com/gengo/grpc-gateway/examples/sub" import ( @@ -77,9 +77,6 @@ func (m *IdMessage) Reset() { *m = IdMessage{} } func (m *IdMessage) String() string { return proto.CompactTextString(m) } func (*IdMessage) ProtoMessage() {} -func init() { -} - // Client API for ABitOfEverythingService service type ABitOfEverythingServiceClient interface { @@ -104,7 +101,7 @@ func NewABitOfEverythingServiceClient(cc *grpc.ClientConn) ABitOfEverythingServi func (c *aBitOfEverythingServiceClient) Create(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) { out := new(ABitOfEverything) - err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.ABitOfEverythingService/Create", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.examplepb.ABitOfEverythingService/Create", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -113,7 +110,7 @@ func (c *aBitOfEverythingServiceClient) Create(ctx context.Context, in *ABitOfEv func (c *aBitOfEverythingServiceClient) CreateBody(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*ABitOfEverything, error) { out := new(ABitOfEverything) - err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.ABitOfEverythingService/CreateBody", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.examplepb.ABitOfEverythingService/CreateBody", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -121,7 +118,7 @@ func (c *aBitOfEverythingServiceClient) CreateBody(ctx context.Context, in *ABit } func (c *aBitOfEverythingServiceClient) BulkCreate(ctx context.Context, opts ...grpc.CallOption) (ABitOfEverythingService_BulkCreateClient, error) { - stream, err := grpc.NewClientStream(ctx, &_ABitOfEverythingService_serviceDesc.Streams[0], c.cc, "/gengo.grpc.gateway.examples.ABitOfEverythingService/BulkCreate", opts...) + stream, err := grpc.NewClientStream(ctx, &_ABitOfEverythingService_serviceDesc.Streams[0], c.cc, "/gengo.grpc.gateway.examples.examplepb.ABitOfEverythingService/BulkCreate", opts...) if err != nil { return nil, err } @@ -156,7 +153,7 @@ func (x *aBitOfEverythingServiceBulkCreateClient) CloseAndRecv() (*EmptyMessage, func (c *aBitOfEverythingServiceClient) Lookup(ctx context.Context, in *IdMessage, opts ...grpc.CallOption) (*ABitOfEverything, error) { out := new(ABitOfEverything) - err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.ABitOfEverythingService/Lookup", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.examplepb.ABitOfEverythingService/Lookup", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -164,7 +161,7 @@ func (c *aBitOfEverythingServiceClient) Lookup(ctx context.Context, in *IdMessag } func (c *aBitOfEverythingServiceClient) List(ctx context.Context, in *EmptyMessage, opts ...grpc.CallOption) (ABitOfEverythingService_ListClient, error) { - stream, err := grpc.NewClientStream(ctx, &_ABitOfEverythingService_serviceDesc.Streams[1], c.cc, "/gengo.grpc.gateway.examples.ABitOfEverythingService/List", opts...) + stream, err := grpc.NewClientStream(ctx, &_ABitOfEverythingService_serviceDesc.Streams[1], c.cc, "/gengo.grpc.gateway.examples.examplepb.ABitOfEverythingService/List", opts...) if err != nil { return nil, err } @@ -197,7 +194,7 @@ func (x *aBitOfEverythingServiceListClient) Recv() (*ABitOfEverything, error) { func (c *aBitOfEverythingServiceClient) Update(ctx context.Context, in *ABitOfEverything, opts ...grpc.CallOption) (*EmptyMessage, error) { out := new(EmptyMessage) - err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.ABitOfEverythingService/Update", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.examplepb.ABitOfEverythingService/Update", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -206,7 +203,7 @@ func (c *aBitOfEverythingServiceClient) Update(ctx context.Context, in *ABitOfEv func (c *aBitOfEverythingServiceClient) Delete(ctx context.Context, in *IdMessage, opts ...grpc.CallOption) (*EmptyMessage, error) { out := new(EmptyMessage) - err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.ABitOfEverythingService/Delete", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.examplepb.ABitOfEverythingService/Delete", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -215,7 +212,7 @@ func (c *aBitOfEverythingServiceClient) Delete(ctx context.Context, in *IdMessag func (c *aBitOfEverythingServiceClient) Echo(ctx context.Context, in *gengo_grpc_gateway_examples_sub.StringMessage, opts ...grpc.CallOption) (*gengo_grpc_gateway_examples_sub.StringMessage, error) { out := new(gengo_grpc_gateway_examples_sub.StringMessage) - err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.ABitOfEverythingService/Echo", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.examplepb.ABitOfEverythingService/Echo", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -223,7 +220,7 @@ func (c *aBitOfEverythingServiceClient) Echo(ctx context.Context, in *gengo_grpc } func (c *aBitOfEverythingServiceClient) BulkEcho(ctx context.Context, opts ...grpc.CallOption) (ABitOfEverythingService_BulkEchoClient, error) { - stream, err := grpc.NewClientStream(ctx, &_ABitOfEverythingService_serviceDesc.Streams[2], c.cc, "/gengo.grpc.gateway.examples.ABitOfEverythingService/BulkEcho", opts...) + stream, err := grpc.NewClientStream(ctx, &_ABitOfEverythingService_serviceDesc.Streams[2], c.cc, "/gengo.grpc.gateway.examples.examplepb.ABitOfEverythingService/BulkEcho", opts...) if err != nil { return nil, err } @@ -271,9 +268,9 @@ func RegisterABitOfEverythingServiceServer(s *grpc.Server, srv ABitOfEverythingS s.RegisterService(&_ABitOfEverythingService_serviceDesc, srv) } -func _ABitOfEverythingService_Create_Handler(srv interface{}, ctx context.Context, buf []byte) (interface{}, error) { +func _ABitOfEverythingService_Create_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { in := new(ABitOfEverything) - if err := proto.Unmarshal(buf, in); err != nil { + if err := codec.Unmarshal(buf, in); err != nil { return nil, err } out, err := srv.(ABitOfEverythingServiceServer).Create(ctx, in) @@ -283,9 +280,9 @@ func _ABitOfEverythingService_Create_Handler(srv interface{}, ctx context.Contex return out, nil } -func _ABitOfEverythingService_CreateBody_Handler(srv interface{}, ctx context.Context, buf []byte) (interface{}, error) { +func _ABitOfEverythingService_CreateBody_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { in := new(ABitOfEverything) - if err := proto.Unmarshal(buf, in); err != nil { + if err := codec.Unmarshal(buf, in); err != nil { return nil, err } out, err := srv.(ABitOfEverythingServiceServer).CreateBody(ctx, in) @@ -321,9 +318,9 @@ func (x *aBitOfEverythingServiceBulkCreateServer) Recv() (*ABitOfEverything, err return m, nil } -func _ABitOfEverythingService_Lookup_Handler(srv interface{}, ctx context.Context, buf []byte) (interface{}, error) { +func _ABitOfEverythingService_Lookup_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { in := new(IdMessage) - if err := proto.Unmarshal(buf, in); err != nil { + if err := codec.Unmarshal(buf, in); err != nil { return nil, err } out, err := srv.(ABitOfEverythingServiceServer).Lookup(ctx, in) @@ -354,9 +351,9 @@ func (x *aBitOfEverythingServiceListServer) Send(m *ABitOfEverything) error { return x.ServerStream.SendMsg(m) } -func _ABitOfEverythingService_Update_Handler(srv interface{}, ctx context.Context, buf []byte) (interface{}, error) { +func _ABitOfEverythingService_Update_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { in := new(ABitOfEverything) - if err := proto.Unmarshal(buf, in); err != nil { + if err := codec.Unmarshal(buf, in); err != nil { return nil, err } out, err := srv.(ABitOfEverythingServiceServer).Update(ctx, in) @@ -366,9 +363,9 @@ func _ABitOfEverythingService_Update_Handler(srv interface{}, ctx context.Contex return out, nil } -func _ABitOfEverythingService_Delete_Handler(srv interface{}, ctx context.Context, buf []byte) (interface{}, error) { +func _ABitOfEverythingService_Delete_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { in := new(IdMessage) - if err := proto.Unmarshal(buf, in); err != nil { + if err := codec.Unmarshal(buf, in); err != nil { return nil, err } out, err := srv.(ABitOfEverythingServiceServer).Delete(ctx, in) @@ -378,9 +375,9 @@ func _ABitOfEverythingService_Delete_Handler(srv interface{}, ctx context.Contex return out, nil } -func _ABitOfEverythingService_Echo_Handler(srv interface{}, ctx context.Context, buf []byte) (interface{}, error) { +func _ABitOfEverythingService_Echo_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { in := new(gengo_grpc_gateway_examples_sub.StringMessage) - if err := proto.Unmarshal(buf, in); err != nil { + if err := codec.Unmarshal(buf, in); err != nil { return nil, err } out, err := srv.(ABitOfEverythingServiceServer).Echo(ctx, in) @@ -417,7 +414,7 @@ func (x *aBitOfEverythingServiceBulkEchoServer) Recv() (*gengo_grpc_gateway_exam } var _ABitOfEverythingService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "gengo.grpc.gateway.examples.ABitOfEverythingService", + ServiceName: "gengo.grpc.gateway.examples.examplepb.ABitOfEverythingService", HandlerType: (*ABitOfEverythingServiceServer)(nil), Methods: []grpc.MethodDesc{ { diff --git a/examples/a_bit_of_everything.pb.gw.go b/examples/examplepb/a_bit_of_everything.pb.gw.go similarity index 99% rename from examples/a_bit_of_everything.pb.gw.go rename to examples/examplepb/a_bit_of_everything.pb.gw.go index 5ff2f5bae04..b2d9f1afa66 100644 --- a/examples/a_bit_of_everything.pb.gw.go +++ b/examples/examplepb/a_bit_of_everything.pb.gw.go @@ -1,13 +1,13 @@ // Code generated by protoc-gen-grpc-gateway -// source: examples/a_bit_of_everything.proto +// source: examples/examplepb/a_bit_of_everything.proto // DO NOT EDIT! /* -Package main is a reverse proxy. +Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ -package main +package examplepb import ( "encoding/json" @@ -15,8 +15,8 @@ import ( "net/http" "github.com/gengo/grpc-gateway/examples/sub" - "github.com/gengo/grpc-gateway/utilities" "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" @@ -44,7 +44,9 @@ func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "float_value") } + protoReq.FloatValue, err = runtime.Float32(val) + if err != nil { return nil, err } @@ -53,7 +55,9 @@ func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "double_value") } + protoReq.DoubleValue, err = runtime.Float64(val) + if err != nil { return nil, err } @@ -62,7 +66,9 @@ func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "int64_value") } + protoReq.Int64Value, err = runtime.Int64(val) + if err != nil { return nil, err } @@ -71,7 +77,9 @@ func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "uint64_value") } + protoReq.Uint64Value, err = runtime.Uint64(val) + if err != nil { return nil, err } @@ -80,7 +88,9 @@ func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "int32_value") } + protoReq.Int32Value, err = runtime.Int32(val) + if err != nil { return nil, err } @@ -89,7 +99,9 @@ func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "fixed64_value") } + protoReq.Fixed64Value, err = runtime.Uint64(val) + if err != nil { return nil, err } @@ -98,7 +110,9 @@ func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "fixed32_value") } + protoReq.Fixed32Value, err = runtime.Uint32(val) + if err != nil { return nil, err } @@ -107,7 +121,9 @@ func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "bool_value") } + protoReq.BoolValue, err = runtime.Bool(val) + if err != nil { return nil, err } @@ -116,7 +132,9 @@ func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "string_value") } + protoReq.StringValue, err = runtime.String(val) + if err != nil { return nil, err } @@ -125,7 +143,9 @@ func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "uint32_value") } + protoReq.Uint32Value, err = runtime.Uint32(val) + if err != nil { return nil, err } @@ -134,7 +154,9 @@ func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "sfixed32_value") } + protoReq.Sfixed32Value, err = runtime.Int32(val) + if err != nil { return nil, err } @@ -143,7 +165,9 @@ func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "sfixed64_value") } + protoReq.Sfixed64Value, err = runtime.Int64(val) + if err != nil { return nil, err } @@ -152,7 +176,9 @@ func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "sint32_value") } + protoReq.Sint32Value, err = runtime.Int32(val) + if err != nil { return nil, err } @@ -161,7 +187,9 @@ func request_ABitOfEverythingService_Create_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "sint64_value") } + protoReq.Sint64Value, err = runtime.Int64(val) + if err != nil { return nil, err } @@ -220,7 +248,9 @@ func request_ABitOfEverythingService_Lookup_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } + protoReq.Uuid, err = runtime.String(val) + if err != nil { return nil, err } @@ -248,7 +278,9 @@ func request_ABitOfEverythingService_Update_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } + protoReq.Uuid, err = runtime.String(val) + if err != nil { return nil, err } @@ -266,7 +298,9 @@ func request_ABitOfEverythingService_Delete_0(ctx context.Context, client ABitOf if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "uuid") } + protoReq.Uuid, err = runtime.String(val) + if err != nil { return nil, err } @@ -284,7 +318,9 @@ func request_ABitOfEverythingService_Echo_0(ctx context.Context, client ABitOfEv if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "value") } + protoReq.Value, err = runtime.StringP(val) + if err != nil { return nil, err } diff --git a/examples/a_bit_of_everything.proto b/examples/examplepb/a_bit_of_everything.proto similarity index 97% rename from examples/a_bit_of_everything.proto rename to examples/examplepb/a_bit_of_everything.proto index c4cf1ee8b32..9586355dce2 100644 --- a/examples/a_bit_of_everything.proto +++ b/examples/examplepb/a_bit_of_everything.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -option go_package = "main"; -package gengo.grpc.gateway.examples; +option go_package = "examplepb"; +package gengo.grpc.gateway.examples.examplepb; import "google/api/annotations.proto"; import "examples/sub/message.proto"; diff --git a/examples/echo_service.pb.go b/examples/examplepb/echo_service.pb.go similarity index 77% rename from examples/echo_service.pb.go rename to examples/examplepb/echo_service.pb.go index 39b3d530fef..daf0fac99d9 100644 --- a/examples/echo_service.pb.go +++ b/examples/examplepb/echo_service.pb.go @@ -1,22 +1,22 @@ // Code generated by protoc-gen-go. -// source: examples/echo_service.proto +// source: examples/examplepb/echo_service.proto // DO NOT EDIT! /* -Package main is a generated protocol buffer package. +Package examplepb is a generated protocol buffer package. It is generated from these files: - examples/echo_service.proto - examples/a_bit_of_everything.proto + examples/examplepb/echo_service.proto + examples/examplepb/a_bit_of_everything.proto It has these top-level messages: SimpleMessage */ -package main +package examplepb import proto "github.com/golang/protobuf/proto" -// discarding unused import google_api1 "google/api/annotations.pb" +// discarding unused import google_api1 "google/api" import ( context "golang.org/x/net/context" @@ -38,9 +38,6 @@ func (m *SimpleMessage) Reset() { *m = SimpleMessage{} } func (m *SimpleMessage) String() string { return proto.CompactTextString(m) } func (*SimpleMessage) ProtoMessage() {} -func init() { -} - // Client API for EchoService service type EchoServiceClient interface { @@ -58,7 +55,7 @@ func NewEchoServiceClient(cc *grpc.ClientConn) EchoServiceClient { func (c *echoServiceClient) Echo(ctx context.Context, in *SimpleMessage, opts ...grpc.CallOption) (*SimpleMessage, error) { out := new(SimpleMessage) - err := grpc.Invoke(ctx, "/gengo.grpc.gateway.example.EchoService/Echo", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.examplepb.EchoService/Echo", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -67,7 +64,7 @@ func (c *echoServiceClient) Echo(ctx context.Context, in *SimpleMessage, opts .. func (c *echoServiceClient) EchoBody(ctx context.Context, in *SimpleMessage, opts ...grpc.CallOption) (*SimpleMessage, error) { out := new(SimpleMessage) - err := grpc.Invoke(ctx, "/gengo.grpc.gateway.example.EchoService/EchoBody", in, out, c.cc, opts...) + err := grpc.Invoke(ctx, "/gengo.grpc.gateway.examples.examplepb.EchoService/EchoBody", in, out, c.cc, opts...) if err != nil { return nil, err } @@ -85,9 +82,9 @@ func RegisterEchoServiceServer(s *grpc.Server, srv EchoServiceServer) { s.RegisterService(&_EchoService_serviceDesc, srv) } -func _EchoService_Echo_Handler(srv interface{}, ctx context.Context, buf []byte) (interface{}, error) { +func _EchoService_Echo_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { in := new(SimpleMessage) - if err := proto.Unmarshal(buf, in); err != nil { + if err := codec.Unmarshal(buf, in); err != nil { return nil, err } out, err := srv.(EchoServiceServer).Echo(ctx, in) @@ -97,9 +94,9 @@ func _EchoService_Echo_Handler(srv interface{}, ctx context.Context, buf []byte) return out, nil } -func _EchoService_EchoBody_Handler(srv interface{}, ctx context.Context, buf []byte) (interface{}, error) { +func _EchoService_EchoBody_Handler(srv interface{}, ctx context.Context, codec grpc.Codec, buf []byte) (interface{}, error) { in := new(SimpleMessage) - if err := proto.Unmarshal(buf, in); err != nil { + if err := codec.Unmarshal(buf, in); err != nil { return nil, err } out, err := srv.(EchoServiceServer).EchoBody(ctx, in) @@ -110,7 +107,7 @@ func _EchoService_EchoBody_Handler(srv interface{}, ctx context.Context, buf []b } var _EchoService_serviceDesc = grpc.ServiceDesc{ - ServiceName: "gengo.grpc.gateway.example.EchoService", + ServiceName: "gengo.grpc.gateway.examples.examplepb.EchoService", HandlerType: (*EchoServiceServer)(nil), Methods: []grpc.MethodDesc{ { diff --git a/examples/echo_service.pb.gw.go b/examples/examplepb/echo_service.pb.gw.go similarity index 97% rename from examples/echo_service.pb.gw.go rename to examples/examplepb/echo_service.pb.gw.go index 51ff107d3a2..ec866879832 100644 --- a/examples/echo_service.pb.gw.go +++ b/examples/examplepb/echo_service.pb.gw.go @@ -1,21 +1,21 @@ // Code generated by protoc-gen-grpc-gateway -// source: examples/echo_service.proto +// source: examples/examplepb/echo_service.proto // DO NOT EDIT! /* -Package main is a reverse proxy. +Package examplepb is a reverse proxy. It translates gRPC into RESTful JSON APIs. */ -package main +package examplepb import ( "encoding/json" "io" "net/http" - "github.com/gengo/grpc-gateway/utilities" "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" @@ -39,7 +39,9 @@ func request_EchoService_Echo_0(ctx context.Context, client EchoServiceClient, r if !ok { return nil, grpc.Errorf(codes.InvalidArgument, "missing parameter %s", "id") } + protoReq.Id, err = runtime.String(val) + if err != nil { return nil, err } diff --git a/examples/echo_service.proto b/examples/examplepb/echo_service.proto similarity index 82% rename from examples/echo_service.proto rename to examples/examplepb/echo_service.proto index f9d5d762847..5e44b2827c6 100644 --- a/examples/echo_service.proto +++ b/examples/examplepb/echo_service.proto @@ -1,6 +1,6 @@ syntax = "proto3"; -option go_package = "main"; -package gengo.grpc.gateway.example; +option go_package = "examplepb"; +package gengo.grpc.gateway.examples.examplepb; import "google/api/annotations.proto"; diff --git a/examples/integration_test.go b/examples/integration_test.go index 65fddc9907b..4382351ab27 100644 --- a/examples/integration_test.go +++ b/examples/integration_test.go @@ -1,4 +1,4 @@ -package main_test +package main import ( "bytes" @@ -12,7 +12,7 @@ import ( "testing" "time" - gw "github.com/gengo/grpc-gateway/examples" + gw "github.com/gengo/grpc-gateway/examples/examplepb" server "github.com/gengo/grpc-gateway/examples/server" sub "github.com/gengo/grpc-gateway/examples/sub" ) @@ -30,7 +30,7 @@ func TestIntegration(t *testing.T) { } }() go func() { - if err := gw.Run(); err != nil { + if err := Run(); err != nil { t.Errorf("gw.Run() failed with %v; want success", err) return } diff --git a/examples/main.go b/examples/main.go index 6836c9b21be..0d4b6f86523 100644 --- a/examples/main.go +++ b/examples/main.go @@ -4,6 +4,7 @@ import ( "flag" "net/http" + "github.com/gengo/grpc-gateway/examples/examplepb" "github.com/gengo/grpc-gateway/runtime" "github.com/golang/glog" "golang.org/x/net/context" @@ -20,11 +21,11 @@ func Run() error { defer cancel() mux := runtime.NewServeMux() - err := RegisterEchoServiceHandlerFromEndpoint(ctx, mux, *echoEndpoint) + err := examplepb.RegisterEchoServiceHandlerFromEndpoint(ctx, mux, *echoEndpoint) if err != nil { return err } - err = RegisterABitOfEverythingServiceHandlerFromEndpoint(ctx, mux, *abeEndpoint) + err = examplepb.RegisterABitOfEverythingServiceHandlerFromEndpoint(ctx, mux, *abeEndpoint) if err != nil { return err } diff --git a/examples/server/main.go b/examples/server/main.go index 2e9463b31a4..a48ef60dcaa 100644 --- a/examples/server/main.go +++ b/examples/server/main.go @@ -7,7 +7,7 @@ import ( "net" "sync" - examples "github.com/gengo/grpc-gateway/examples" + examples "github.com/gengo/grpc-gateway/examples/examplepb" sub "github.com/gengo/grpc-gateway/examples/sub" "github.com/golang/glog" "github.com/rogpeppe/fastuuid" diff --git a/examples/sub/message.pb.go b/examples/sub/message.pb.go index 9ad656dfaed..04be0cc748e 100644 --- a/examples/sub/message.pb.go +++ b/examples/sub/message.pb.go @@ -35,6 +35,3 @@ func (m *StringMessage) GetValue() string { } return "" } - -func init() { -} diff --git a/third_party/googleapis/google/api/http.pb.go b/third_party/googleapis/google/api/http.pb.go index 27e77746807..17730b915b3 100644 --- a/third_party/googleapis/google/api/http.pb.go +++ b/third_party/googleapis/google/api/http.pb.go @@ -121,6 +121,3 @@ type CustomHttpPattern struct { func (m *CustomHttpPattern) Reset() { *m = CustomHttpPattern{} } func (m *CustomHttpPattern) String() string { return proto.CompactTextString(m) } func (*CustomHttpPattern) ProtoMessage() {} - -func init() { -}