diff --git a/proto/test.pb.go b/proto/test.pb.go index 9028bc7..27232e7 100644 --- a/proto/test.pb.go +++ b/proto/test.pb.go @@ -7,6 +7,7 @@ import ( context "context" fmt "fmt" proto "github.com/golang/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -25,7 +26,8 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package type Request struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + Uuid string `protobuf:"bytes,1,opt,name=uuid,proto3" json:"uuid,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -56,6 +58,13 @@ func (m *Request) XXX_DiscardUnknown() { var xxx_messageInfo_Request proto.InternalMessageInfo +func (m *Request) GetUuid() string { + if m != nil { + return m.Uuid + } + return "" +} + func (m *Request) GetName() string { if m != nil { return m.Name @@ -110,16 +119,20 @@ func init() { func init() { proto.RegisterFile("server/grpc/proto/test.proto", fileDescriptor_bb9c685b7640cf1e) } var fileDescriptor_bb9c685b7640cf1e = []byte{ - // 132 bytes of a gzipped FileDescriptorProto + // 198 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x29, 0x4e, 0x2d, 0x2a, 0x4b, 0x2d, 0xd2, 0x4f, 0x2f, 0x2a, 0x48, 0xd6, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0xd7, 0x2f, 0x49, - 0x2d, 0x2e, 0xd1, 0x03, 0x33, 0x95, 0x64, 0xb9, 0xd8, 0x83, 0x52, 0x0b, 0x4b, 0x53, 0x8b, 0x4b, - 0x84, 0x84, 0xb8, 0x58, 0xf2, 0x12, 0x73, 0x53, 0x25, 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0xc0, - 0x6c, 0x25, 0x19, 0x2e, 0x8e, 0xa0, 0xd4, 0xe2, 0x82, 0xfc, 0xbc, 0xe2, 0x54, 0x21, 0x01, 0x2e, - 0xe6, 0xdc, 0xe2, 0x74, 0xa8, 0x34, 0x88, 0x69, 0xa4, 0xca, 0xc5, 0x12, 0x02, 0xd2, 0x29, 0xcb, - 0xc5, 0xe2, 0x9c, 0x98, 0x93, 0x23, 0xc4, 0xa1, 0x07, 0x35, 0x4b, 0x8a, 0x53, 0x0f, 0xa6, 0x4d, - 0x89, 0x21, 0x89, 0x0d, 0x6c, 0x95, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xe6, 0xc8, 0xea, 0xc1, - 0x8a, 0x00, 0x00, 0x00, + 0x2d, 0x2e, 0xd1, 0x03, 0x33, 0xa5, 0x64, 0xd2, 0xf3, 0xf3, 0xd3, 0x73, 0x52, 0xf5, 0x13, 0x0b, + 0x32, 0xf5, 0x13, 0xf3, 0xf2, 0xf2, 0x4b, 0x12, 0x4b, 0x32, 0xf3, 0xf3, 0x8a, 0x21, 0xb2, 0x4a, + 0x86, 0x5c, 0xec, 0x41, 0xa9, 0x85, 0xa5, 0xa9, 0xc5, 0x25, 0x42, 0x42, 0x5c, 0x2c, 0xa5, 0xa5, + 0x99, 0x29, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x60, 0x36, 0x48, 0x2c, 0x2f, 0x31, 0x37, + 0x55, 0x82, 0x09, 0x22, 0x06, 0x62, 0x2b, 0xc9, 0x70, 0x71, 0x04, 0xa5, 0x16, 0x17, 0xe4, 0xe7, + 0x15, 0xa7, 0x0a, 0x09, 0x70, 0x31, 0xe7, 0x16, 0xa7, 0x43, 0xb5, 0x80, 0x98, 0x46, 0x1e, 0x5c, + 0x2c, 0x21, 0x20, 0xd3, 0x1c, 0xb8, 0x58, 0x9c, 0x13, 0x73, 0x72, 0x84, 0x38, 0xf4, 0xa0, 0xe6, + 0x4b, 0x71, 0xea, 0xc1, 0xb4, 0x29, 0x29, 0x37, 0x5d, 0x7e, 0x32, 0x99, 0x49, 0x56, 0x49, 0x02, + 0xec, 0xaa, 0x32, 0x03, 0xb0, 0x7b, 0xf5, 0x93, 0x13, 0x73, 0x72, 0xf4, 0xab, 0x41, 0xf6, 0xd6, + 0x5a, 0x31, 0x6a, 0x25, 0xb1, 0x81, 0x5d, 0x68, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0xd0, 0xc1, + 0x00, 0x50, 0xdf, 0x00, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/test.pb.micro.go b/proto/test.pb.micro.go index a06bd3e..46c7644 100644 --- a/proto/test.pb.micro.go +++ b/proto/test.pb.micro.go @@ -6,11 +6,13 @@ package test import ( fmt "fmt" proto "github.com/golang/protobuf/proto" + _ "google.golang.org/genproto/googleapis/api/annotations" math "math" ) import ( context "context" + api "github.com/micro/go-micro/v2/api" client "github.com/micro/go-micro/v2/client" server "github.com/micro/go-micro/v2/server" ) @@ -27,10 +29,24 @@ var _ = math.Inf const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package // Reference imports to suppress errors if they are not otherwise used. +var _ api.Endpoint var _ context.Context var _ client.Option var _ server.Option +// Api Endpoints for Test service + +func NewTestEndpoints() []*api.Endpoint { + return []*api.Endpoint{ + &api.Endpoint{ + Name: "Test.Call", + Path: []string{"/api/v0/test/call/{uuid}"}, + Method: []string{"POST"}, + Handler: "rpc", + }, + } +} + // Client API for Test service type TestService interface { @@ -73,6 +89,12 @@ func RegisterTestHandler(s server.Server, hdlr TestHandler, opts ...server.Handl test } h := &testHandler{hdlr} + opts = append(opts, api.WithEndpoint(&api.Endpoint{ + Name: "Test.Call", + Path: []string{"/api/v0/test/call/{uuid}"}, + Method: []string{"POST"}, + Handler: "rpc", + })) return s.Handle(s.NewHandler(&Test{h}, opts...)) } diff --git a/proto/test.proto b/proto/test.proto index 0dbbea9..cbef20e 100644 --- a/proto/test.proto +++ b/proto/test.proto @@ -1,11 +1,17 @@ syntax = "proto3"; +import "google/api/annotations.proto"; + service Test { - rpc Call(Request) returns (Response) {} + rpc Call(Request) returns (Response) { + option (google.api.http) = { post: "/api/v0/test/call/{uuid}"; body:"*"; }; + }; + } message Request { - string name = 1; + string uuid = 1; + string name = 2; } message Response {