Create & Init Project...
This commit is contained in:
@ -0,0 +1,44 @@
|
||||
// Package v1 Code generated by go-common/app/tool/protoc-gen-bm. DO NOT EDIT.
|
||||
package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
bm "go-common/library/net/http/blademaster"
|
||||
)
|
||||
|
||||
// BMHelloServer interface as same as gGRPC server define
|
||||
type BMHelloServer interface {
|
||||
SayHello(context.Context, *HelloRequest) (*HelloReply, error)
|
||||
Echo(context.Context, *EchoRequest) (*EchoReply, error)
|
||||
}
|
||||
|
||||
// _BMServerHelloserver
|
||||
type _BMServerHello struct {
|
||||
BMHelloServer
|
||||
}
|
||||
|
||||
func (b *_BMServerHello) bmHelloSayHelloHandler(c *bm.Context) {
|
||||
req := new(HelloRequest)
|
||||
if err := c.Bind(req); err != nil {
|
||||
return
|
||||
}
|
||||
reply, err := b.SayHello(c.Context, req)
|
||||
c.JSON(reply, err)
|
||||
}
|
||||
|
||||
func (b *_BMServerHello) bmHelloEchoHandler(c *bm.Context) {
|
||||
req := new(EchoRequest)
|
||||
if err := c.Bind(req); err != nil {
|
||||
return
|
||||
}
|
||||
reply, err := b.Echo(c.Context, req)
|
||||
c.JSON(reply, err)
|
||||
}
|
||||
|
||||
// RegisterHelloBMServer register bm server
|
||||
func RegisterHelloBMServer(e *bm.Engine, s BMHelloServer) {
|
||||
bs := &_BMServerHello{s}
|
||||
e.GET("/hello", bs.bmHelloSayHelloHandler)
|
||||
e.POST("/echo", bs.bmHelloEchoHandler)
|
||||
}
|
318
app/tool/protoc-gen-bm/examples/helloworld/api/helloworld.pb.go
Normal file
318
app/tool/protoc-gen-bm/examples/helloworld/api/helloworld.pb.go
Normal file
@ -0,0 +1,318 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// source: examples/helloworld/api/helloworld.proto
|
||||
|
||||
package v1
|
||||
|
||||
import proto "github.com/golang/protobuf/proto"
|
||||
import fmt "fmt"
|
||||
import math "math"
|
||||
import _ "google.golang.org/genproto/googleapis/api/annotations"
|
||||
|
||||
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
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the proto package it is being compiled against.
|
||||
// A compilation error at this line likely means your copy of the
|
||||
// proto package needs to be updated.
|
||||
const _ = proto.ProtoPackageIsVersion2 // please upgrade the proto package
|
||||
|
||||
// The request message containing the user's name.
|
||||
type HelloRequest struct {
|
||||
Name string `protobuf:"bytes,1,opt,name=name" json:"name,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *HelloRequest) Reset() { *m = HelloRequest{} }
|
||||
func (m *HelloRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*HelloRequest) ProtoMessage() {}
|
||||
func (*HelloRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_helloworld_240ffe8e5d7496cc, []int{0}
|
||||
}
|
||||
func (m *HelloRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_HelloRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *HelloRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_HelloRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *HelloRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_HelloRequest.Merge(dst, src)
|
||||
}
|
||||
func (m *HelloRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_HelloRequest.Size(m)
|
||||
}
|
||||
func (m *HelloRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_HelloRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_HelloRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *HelloRequest) GetName() string {
|
||||
if m != nil {
|
||||
return m.Name
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// The response message containing the greetings
|
||||
type HelloReply struct {
|
||||
Message string `protobuf:"bytes,1,opt,name=message" json:"message,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *HelloReply) Reset() { *m = HelloReply{} }
|
||||
func (m *HelloReply) String() string { return proto.CompactTextString(m) }
|
||||
func (*HelloReply) ProtoMessage() {}
|
||||
func (*HelloReply) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_helloworld_240ffe8e5d7496cc, []int{1}
|
||||
}
|
||||
func (m *HelloReply) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_HelloReply.Unmarshal(m, b)
|
||||
}
|
||||
func (m *HelloReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_HelloReply.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *HelloReply) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_HelloReply.Merge(dst, src)
|
||||
}
|
||||
func (m *HelloReply) XXX_Size() int {
|
||||
return xxx_messageInfo_HelloReply.Size(m)
|
||||
}
|
||||
func (m *HelloReply) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_HelloReply.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_HelloReply proto.InternalMessageInfo
|
||||
|
||||
func (m *HelloReply) GetMessage() string {
|
||||
if m != nil {
|
||||
return m.Message
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type EchoRequest struct {
|
||||
Content string `protobuf:"bytes,1,opt,name=content" json:"content,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *EchoRequest) Reset() { *m = EchoRequest{} }
|
||||
func (m *EchoRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*EchoRequest) ProtoMessage() {}
|
||||
func (*EchoRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_helloworld_240ffe8e5d7496cc, []int{2}
|
||||
}
|
||||
func (m *EchoRequest) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_EchoRequest.Unmarshal(m, b)
|
||||
}
|
||||
func (m *EchoRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_EchoRequest.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *EchoRequest) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_EchoRequest.Merge(dst, src)
|
||||
}
|
||||
func (m *EchoRequest) XXX_Size() int {
|
||||
return xxx_messageInfo_EchoRequest.Size(m)
|
||||
}
|
||||
func (m *EchoRequest) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_EchoRequest.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_EchoRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *EchoRequest) GetContent() string {
|
||||
if m != nil {
|
||||
return m.Content
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type EchoReply struct {
|
||||
Content string `protobuf:"bytes,1,opt,name=content" json:"content,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
}
|
||||
|
||||
func (m *EchoReply) Reset() { *m = EchoReply{} }
|
||||
func (m *EchoReply) String() string { return proto.CompactTextString(m) }
|
||||
func (*EchoReply) ProtoMessage() {}
|
||||
func (*EchoReply) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_helloworld_240ffe8e5d7496cc, []int{3}
|
||||
}
|
||||
func (m *EchoReply) XXX_Unmarshal(b []byte) error {
|
||||
return xxx_messageInfo_EchoReply.Unmarshal(m, b)
|
||||
}
|
||||
func (m *EchoReply) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
return xxx_messageInfo_EchoReply.Marshal(b, m, deterministic)
|
||||
}
|
||||
func (dst *EchoReply) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_EchoReply.Merge(dst, src)
|
||||
}
|
||||
func (m *EchoReply) XXX_Size() int {
|
||||
return xxx_messageInfo_EchoReply.Size(m)
|
||||
}
|
||||
func (m *EchoReply) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_EchoReply.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_EchoReply proto.InternalMessageInfo
|
||||
|
||||
func (m *EchoReply) GetContent() string {
|
||||
if m != nil {
|
||||
return m.Content
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*HelloRequest)(nil), "helloworld.v1.HelloRequest")
|
||||
proto.RegisterType((*HelloReply)(nil), "helloworld.v1.HelloReply")
|
||||
proto.RegisterType((*EchoRequest)(nil), "helloworld.v1.EchoRequest")
|
||||
proto.RegisterType((*EchoReply)(nil), "helloworld.v1.EchoReply")
|
||||
}
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ context.Context
|
||||
var _ grpc.ClientConn
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc.SupportPackageIsVersion4
|
||||
|
||||
// Client API for Hello service
|
||||
|
||||
type HelloClient interface {
|
||||
// Sends a greeting
|
||||
SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error)
|
||||
Echo(ctx context.Context, in *EchoRequest, opts ...grpc.CallOption) (*EchoReply, error)
|
||||
}
|
||||
|
||||
type helloClient struct {
|
||||
cc *grpc.ClientConn
|
||||
}
|
||||
|
||||
func NewHelloClient(cc *grpc.ClientConn) HelloClient {
|
||||
return &helloClient{cc}
|
||||
}
|
||||
|
||||
func (c *helloClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) {
|
||||
out := new(HelloReply)
|
||||
err := grpc.Invoke(ctx, "/helloworld.v1.Hello/SayHello", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (c *helloClient) Echo(ctx context.Context, in *EchoRequest, opts ...grpc.CallOption) (*EchoReply, error) {
|
||||
out := new(EchoReply)
|
||||
err := grpc.Invoke(ctx, "/helloworld.v1.Hello/Echo", in, out, c.cc, opts...)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// Server API for Hello service
|
||||
|
||||
type HelloServer interface {
|
||||
// Sends a greeting
|
||||
SayHello(context.Context, *HelloRequest) (*HelloReply, error)
|
||||
Echo(context.Context, *EchoRequest) (*EchoReply, error)
|
||||
}
|
||||
|
||||
func RegisterHelloServer(s *grpc.Server, srv HelloServer) {
|
||||
s.RegisterService(&_Hello_serviceDesc, srv)
|
||||
}
|
||||
|
||||
func _Hello_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(HelloRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HelloServer).SayHello(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/helloworld.v1.Hello/SayHello",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HelloServer).SayHello(ctx, req.(*HelloRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Hello_Echo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(EchoRequest)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if interceptor == nil {
|
||||
return srv.(HelloServer).Echo(ctx, in)
|
||||
}
|
||||
info := &grpc.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: "/helloworld.v1.Hello/Echo",
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
return srv.(HelloServer).Echo(ctx, req.(*EchoRequest))
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
var _Hello_serviceDesc = grpc.ServiceDesc{
|
||||
ServiceName: "helloworld.v1.Hello",
|
||||
HandlerType: (*HelloServer)(nil),
|
||||
Methods: []grpc.MethodDesc{
|
||||
{
|
||||
MethodName: "SayHello",
|
||||
Handler: _Hello_SayHello_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Echo",
|
||||
Handler: _Hello_Echo_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc.StreamDesc{},
|
||||
Metadata: "examples/helloworld/api/helloworld.proto",
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterFile("examples/helloworld/api/helloworld.proto", fileDescriptor_helloworld_240ffe8e5d7496cc)
|
||||
}
|
||||
|
||||
var fileDescriptor_helloworld_240ffe8e5d7496cc = []byte{
|
||||
// 258 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x48, 0xad, 0x48, 0xcc,
|
||||
0x2d, 0xc8, 0x49, 0x2d, 0xd6, 0xcf, 0x48, 0xcd, 0xc9, 0xc9, 0x2f, 0xcf, 0x2f, 0xca, 0x49, 0xd1,
|
||||
0x4f, 0x2c, 0xc8, 0x44, 0xe2, 0xea, 0x15, 0x14, 0xe5, 0x97, 0xe4, 0x0b, 0xf1, 0x22, 0x89, 0x94,
|
||||
0x19, 0x4a, 0xc9, 0xa4, 0xe7, 0xe7, 0xa7, 0xe7, 0xa4, 0x82, 0xd5, 0x26, 0xe6, 0xe5, 0xe5, 0x97,
|
||||
0x24, 0x96, 0x64, 0xe6, 0xe7, 0x15, 0x43, 0x14, 0x2b, 0x29, 0x71, 0xf1, 0x78, 0x80, 0x94, 0x07,
|
||||
0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x08, 0x09, 0x71, 0xb1, 0xe4, 0x25, 0xe6, 0xa6, 0x4a, 0x30,
|
||||
0x2a, 0x30, 0x6a, 0x70, 0x06, 0x81, 0xd9, 0x4a, 0x6a, 0x5c, 0x5c, 0x50, 0x35, 0x05, 0x39, 0x95,
|
||||
0x42, 0x12, 0x5c, 0xec, 0xb9, 0xa9, 0xc5, 0xc5, 0x89, 0xe9, 0x30, 0x45, 0x30, 0xae, 0x92, 0x3a,
|
||||
0x17, 0xb7, 0x6b, 0x72, 0x06, 0xdc, 0x28, 0x09, 0x2e, 0xf6, 0xe4, 0xfc, 0xbc, 0x92, 0xd4, 0xbc,
|
||||
0x12, 0x98, 0x42, 0x28, 0x57, 0x49, 0x95, 0x8b, 0x13, 0xa2, 0x10, 0x6a, 0x1e, 0x76, 0x65, 0x46,
|
||||
0x2b, 0x18, 0xb9, 0x58, 0xc1, 0x16, 0x0b, 0x05, 0x71, 0x71, 0x04, 0x27, 0x56, 0x42, 0xd8, 0xd2,
|
||||
0x7a, 0x28, 0xfe, 0xd3, 0x43, 0x76, 0xbe, 0x94, 0x24, 0x76, 0xc9, 0x82, 0x9c, 0x4a, 0x25, 0xbe,
|
||||
0xa6, 0xcb, 0x4f, 0x26, 0x33, 0x71, 0x08, 0xb1, 0x41, 0x42, 0x4c, 0xc8, 0x9b, 0x8b, 0x05, 0xe4,
|
||||
0x08, 0x21, 0x29, 0x34, 0x2d, 0x48, 0x5e, 0x90, 0x92, 0xc0, 0x2a, 0x07, 0x32, 0x8d, 0x17, 0x6c,
|
||||
0x1a, 0xbb, 0x12, 0xab, 0x7e, 0x6a, 0x72, 0x46, 0xbe, 0x13, 0x4b, 0x14, 0x53, 0x99, 0x61, 0x12,
|
||||
0x1b, 0x38, 0x4c, 0x8d, 0x01, 0x01, 0x00, 0x00, 0xff, 0xff, 0x4a, 0x51, 0xfb, 0x90, 0xac, 0x01,
|
||||
0x00, 0x00,
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
syntax = "proto3";
|
||||
package helloworld.v1;
|
||||
|
||||
import "google/api/annotations.proto";
|
||||
|
||||
option go_package = "v1";
|
||||
|
||||
// The greeting service definition.
|
||||
service Hello {
|
||||
// Sends a greeting
|
||||
rpc SayHello (HelloRequest) returns (HelloReply) {
|
||||
option (google.api.http) = {
|
||||
get:"/hello"
|
||||
};
|
||||
}
|
||||
rpc Echo(EchoRequest) returns (EchoReply) {
|
||||
option (google.api.http) = {
|
||||
post:"/echo"
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// The request message containing the user's name.
|
||||
message HelloRequest {
|
||||
string name = 1;
|
||||
}
|
||||
|
||||
// The response message containing the greetings
|
||||
message HelloReply {
|
||||
string message = 1;
|
||||
}
|
||||
|
||||
message EchoRequest {
|
||||
string content = 1;
|
||||
}
|
||||
|
||||
message EchoReply {
|
||||
string content = 1;
|
||||
}
|
Reference in New Issue
Block a user