Documentation
¶
Overview ¶
Package api is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func RegisterMyServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterMyServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MyServiceClient) error
- func RegisterMyServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterMyServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MyServiceServer) error
- func RegisterMyServiceServer(s *grpc.Server, srv MyServiceServer)
- type AddressBook
- type MyServiceClient
- type MyServiceServer
- type Person
- func (*Person) Descriptor() ([]byte, []int)deprecated
- func (x *Person) GetEmail() string
- func (x *Person) GetId() int32
- func (x *Person) GetName() string
- func (x *Person) GetPhones() []*Person_PhoneNumber
- func (*Person) ProtoMessage()
- func (x *Person) ProtoReflect() protoreflect.Message
- func (x *Person) Reset()
- func (x *Person) String() string
- type Person_PhoneNumber
- func (*Person_PhoneNumber) Descriptor() ([]byte, []int)deprecated
- func (x *Person_PhoneNumber) GetNumber() string
- func (x *Person_PhoneNumber) GetType() Person_PhoneType
- func (*Person_PhoneNumber) ProtoMessage()
- func (x *Person_PhoneNumber) ProtoReflect() protoreflect.Message
- func (x *Person_PhoneNumber) Reset()
- func (x *Person_PhoneNumber) String() string
- type Person_PhoneType
- func (Person_PhoneType) Descriptor() protoreflect.EnumDescriptor
- func (x Person_PhoneType) Enum() *Person_PhoneType
- func (Person_PhoneType) EnumDescriptor() ([]byte, []int)deprecated
- func (x Person_PhoneType) Number() protoreflect.EnumNumber
- func (x Person_PhoneType) String() string
- func (Person_PhoneType) Type() protoreflect.EnumType
- type StringMessage
- func (*StringMessage) Descriptor() ([]byte, []int)deprecated
- func (x *StringMessage) GetCreate() *timestamp.Timestamp
- func (x *StringMessage) GetP() *Person
- func (x *StringMessage) GetValue() string
- func (*StringMessage) ProtoMessage()
- func (x *StringMessage) ProtoReflect() protoreflect.Message
- func (x *StringMessage) Reset()
- func (x *StringMessage) String() string
- type UnimplementedMyServiceServer
Constants ¶
This section is empty.
Variables ¶
var ( Person_PhoneType_name = map[int32]string{ 0: "MOBILE", 1: "HOME", 2: "WORK", } Person_PhoneType_value = map[string]int32{ "MOBILE": 0, "HOME": 1, "WORK": 2, } )
Enum value maps for Person_PhoneType.
var File_api_message_proto protoreflect.FileDescriptor
var File_api_service_proto protoreflect.FileDescriptor
Functions ¶
func RegisterMyServiceHandler ¶
func RegisterMyServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
RegisterMyServiceHandler registers the http handlers for service MyService to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterMyServiceHandlerClient ¶
func RegisterMyServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MyServiceClient) error
RegisterMyServiceHandlerClient registers the http handlers for service MyService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MyServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MyServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "MyServiceClient" to call the correct interceptors.
func RegisterMyServiceHandlerFromEndpoint ¶
func RegisterMyServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterMyServiceHandlerFromEndpoint is same as RegisterMyServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterMyServiceHandlerServer ¶
func RegisterMyServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MyServiceServer) error
RegisterMyServiceHandlerServer registers the http handlers for service MyService to "mux". UnaryRPC :call MyServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
func RegisterMyServiceServer ¶
func RegisterMyServiceServer(s *grpc.Server, srv MyServiceServer)
Types ¶
type AddressBook ¶
type AddressBook struct { People []*Person `protobuf:"bytes,1,rep,name=people,proto3" json:"people,omitempty"` // contains filtered or unexported fields }
Our address book file is just one of these.
func (*AddressBook) Descriptor
deprecated
func (*AddressBook) Descriptor() ([]byte, []int)
Deprecated: Use AddressBook.ProtoReflect.Descriptor instead.
func (*AddressBook) GetPeople ¶
func (x *AddressBook) GetPeople() []*Person
func (*AddressBook) ProtoMessage ¶
func (*AddressBook) ProtoMessage()
func (*AddressBook) ProtoReflect ¶
func (x *AddressBook) ProtoReflect() protoreflect.Message
func (*AddressBook) Reset ¶
func (x *AddressBook) Reset()
func (*AddressBook) String ¶
func (x *AddressBook) String() string
type MyServiceClient ¶
type MyServiceClient interface {
Echo(ctx context.Context, in *StringMessage, opts ...grpc.CallOption) (*Person, error)
}
MyServiceClient is the client API for MyService service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewMyServiceClient ¶
func NewMyServiceClient(cc grpc.ClientConnInterface) MyServiceClient
type MyServiceServer ¶
type MyServiceServer interface {
Echo(context.Context, *StringMessage) (*Person, error)
}
MyServiceServer is the server API for MyService service.
type Person ¶
type Person struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Id int32 `protobuf:"varint,2,opt,name=id,proto3" json:"id,omitempty"` // Unique ID number for this person. Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` Phones []*Person_PhoneNumber `protobuf:"bytes,4,rep,name=phones,proto3" json:"phones,omitempty"` // contains filtered or unexported fields }
目录
func (*Person) Descriptor
deprecated
func (*Person) GetPhones ¶
func (x *Person) GetPhones() []*Person_PhoneNumber
func (*Person) ProtoMessage ¶
func (*Person) ProtoMessage()
func (*Person) ProtoReflect ¶
func (x *Person) ProtoReflect() protoreflect.Message
type Person_PhoneNumber ¶
type Person_PhoneNumber struct { Number string `protobuf:"bytes,1,opt,name=number,proto3" json:"number,omitempty"` Type Person_PhoneType `protobuf:"varint,2,opt,name=type,proto3,enum=api.Person_PhoneType" json:"type,omitempty"` // contains filtered or unexported fields }
func (*Person_PhoneNumber) Descriptor
deprecated
func (*Person_PhoneNumber) Descriptor() ([]byte, []int)
Deprecated: Use Person_PhoneNumber.ProtoReflect.Descriptor instead.
func (*Person_PhoneNumber) GetNumber ¶
func (x *Person_PhoneNumber) GetNumber() string
func (*Person_PhoneNumber) GetType ¶
func (x *Person_PhoneNumber) GetType() Person_PhoneType
func (*Person_PhoneNumber) ProtoMessage ¶
func (*Person_PhoneNumber) ProtoMessage()
func (*Person_PhoneNumber) ProtoReflect ¶
func (x *Person_PhoneNumber) ProtoReflect() protoreflect.Message
func (*Person_PhoneNumber) Reset ¶
func (x *Person_PhoneNumber) Reset()
func (*Person_PhoneNumber) String ¶
func (x *Person_PhoneNumber) String() string
type Person_PhoneType ¶
type Person_PhoneType int32
const ( Person_MOBILE Person_PhoneType = 0 Person_HOME Person_PhoneType = 1 Person_WORK Person_PhoneType = 2 )
func (Person_PhoneType) Descriptor ¶
func (Person_PhoneType) Descriptor() protoreflect.EnumDescriptor
func (Person_PhoneType) Enum ¶
func (x Person_PhoneType) Enum() *Person_PhoneType
func (Person_PhoneType) EnumDescriptor
deprecated
func (Person_PhoneType) EnumDescriptor() ([]byte, []int)
Deprecated: Use Person_PhoneType.Descriptor instead.
func (Person_PhoneType) Number ¶
func (x Person_PhoneType) Number() protoreflect.EnumNumber
func (Person_PhoneType) String ¶
func (x Person_PhoneType) String() string
func (Person_PhoneType) Type ¶
func (Person_PhoneType) Type() protoreflect.EnumType
type StringMessage ¶
type StringMessage struct { Value string `protobuf:"bytes,1,opt,name=value,proto3" json:"value,omitempty"` P *Person `protobuf:"bytes,3,opt,name=p,proto3" json:"p,omitempty"` Create *timestamp.Timestamp `protobuf:"bytes,2,opt,name=create,proto3" json:"create,omitempty"` // contains filtered or unexported fields }
func (*StringMessage) Descriptor
deprecated
func (*StringMessage) Descriptor() ([]byte, []int)
Deprecated: Use StringMessage.ProtoReflect.Descriptor instead.
func (*StringMessage) GetCreate ¶
func (x *StringMessage) GetCreate() *timestamp.Timestamp
func (*StringMessage) GetP ¶
func (x *StringMessage) GetP() *Person
func (*StringMessage) GetValue ¶
func (x *StringMessage) GetValue() string
func (*StringMessage) ProtoMessage ¶
func (*StringMessage) ProtoMessage()
func (*StringMessage) ProtoReflect ¶
func (x *StringMessage) ProtoReflect() protoreflect.Message
func (*StringMessage) Reset ¶
func (x *StringMessage) Reset()
func (*StringMessage) String ¶
func (x *StringMessage) String() string
type UnimplementedMyServiceServer ¶
type UnimplementedMyServiceServer struct { }
UnimplementedMyServiceServer can be embedded to have forward compatible implementations.
func (*UnimplementedMyServiceServer) Echo ¶
func (*UnimplementedMyServiceServer) Echo(context.Context, *StringMessage) (*Person, error)