Documentation ¶
Overview ¶
Package v1 is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func RegisterUserHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterUserHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserClient) error
- func RegisterUserHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterUserHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServer) error
- func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer)
- type PingMsg
- type PingReply
- func (*PingReply) Descriptor() ([]byte, []int)deprecated
- func (x *PingReply) GetCode() int64
- func (x *PingReply) GetData() *PingMsg
- func (x *PingReply) GetMsg() string
- func (*PingReply) ProtoMessage()
- func (x *PingReply) ProtoReflect() protoreflect.Message
- func (x *PingReply) Reset()
- func (x *PingReply) String() string
- type PingReq
- type UnimplementedUserServer
- func (UnimplementedUserServer) CreateUser(context.Context, *UserReq) (*UserReply, error)
- func (UnimplementedUserServer) DeleteUser(context.Context, *UserReq) (*UserReply, error)
- func (UnimplementedUserServer) Ping(context.Context, *PingReq) (*PingReply, error)
- func (UnimplementedUserServer) ReadUser(context.Context, *UserReq) (*UserReply, error)
- func (UnimplementedUserServer) UpdateUser(context.Context, *UserReq) (*UserReply, error)
- type UnsafeUserServer
- type UserClient
- type UserMsg
- func (*UserMsg) Descriptor() ([]byte, []int)deprecated
- func (x *UserMsg) GetName() string
- func (x *UserMsg) GetSex() int64
- func (x *UserMsg) GetUid() int64
- func (*UserMsg) ProtoMessage()
- func (x *UserMsg) ProtoReflect() protoreflect.Message
- func (x *UserMsg) Reset()
- func (x *UserMsg) String() string
- type UserReply
- func (*UserReply) Descriptor() ([]byte, []int)deprecated
- func (x *UserReply) GetCode() int64
- func (x *UserReply) GetData() *UserMsg
- func (x *UserReply) GetMsg() string
- func (*UserReply) ProtoMessage()
- func (x *UserReply) ProtoReflect() protoreflect.Message
- func (x *UserReply) Reset()
- func (x *UserReply) String() string
- type UserReq
- type UserServer
Constants ¶
This section is empty.
Variables ¶
var File_api_proto protoreflect.FileDescriptor
Functions ¶
func RegisterUserHandler ¶
RegisterUserHandler registers the http handlers for service User to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterUserHandlerClient ¶
RegisterUserHandlerClient registers the http handlers for service User to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UserClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UserClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "UserClient" to call the correct interceptors.
func RegisterUserHandlerFromEndpoint ¶
func RegisterUserHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterUserHandlerFromEndpoint is same as RegisterUserHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterUserHandlerServer ¶
RegisterUserHandlerServer registers the http handlers for service User to "mux". UnaryRPC :call UserServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterUserHandlerFromEndpoint instead.
func RegisterUserServer ¶
func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer)
Types ¶
type PingMsg ¶ added in v1.11.0
type PingMsg struct { Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` Count int64 `protobuf:"zigzag64,2,opt,name=count,proto3" json:"count,omitempty"` // contains filtered or unexported fields }
ping message
func (*PingMsg) Descriptor
deprecated
added in
v1.11.0
func (*PingMsg) GetMessage ¶ added in v1.11.0
func (*PingMsg) ProtoMessage ¶ added in v1.11.0
func (*PingMsg) ProtoMessage()
func (*PingMsg) ProtoReflect ¶ added in v1.11.0
func (x *PingMsg) ProtoReflect() protoreflect.Message
type PingReply ¶ added in v1.11.0
type PingReply struct { // 业务错误码 Code int64 `protobuf:"zigzag64,1,opt,name=code,proto3" json:"code,omitempty"` // 业务错误信息 Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` // 业务数据 Data *PingMsg `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` // contains filtered or unexported fields }
ping reply
func (*PingReply) Descriptor
deprecated
added in
v1.11.0
func (*PingReply) ProtoMessage ¶ added in v1.11.0
func (*PingReply) ProtoMessage()
func (*PingReply) ProtoReflect ¶ added in v1.11.0
func (x *PingReply) ProtoReflect() protoreflect.Message
type PingReq ¶ added in v1.11.0
type PingReq struct { // 业务数据 Data *PingMsg `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` // contains filtered or unexported fields }
ping request
func (*PingReq) Descriptor
deprecated
added in
v1.11.0
func (*PingReq) ProtoMessage ¶ added in v1.11.0
func (*PingReq) ProtoMessage()
func (*PingReq) ProtoReflect ¶ added in v1.11.0
func (x *PingReq) ProtoReflect() protoreflect.Message
type UnimplementedUserServer ¶
type UnimplementedUserServer struct { }
UnimplementedUserServer should be embedded to have forward compatible implementations.
func (UnimplementedUserServer) CreateUser ¶
func (UnimplementedUserServer) DeleteUser ¶
func (UnimplementedUserServer) UpdateUser ¶
type UnsafeUserServer ¶ added in v1.11.0
type UnsafeUserServer interface {
// contains filtered or unexported methods
}
UnsafeUserServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to UserServer will result in compilation errors.
type UserClient ¶
type UserClient interface { // ping by message Ping(ctx context.Context, in *PingReq, opts ...grpc.CallOption) (*PingReply, error) // create user by user data CreateUser(ctx context.Context, in *UserReq, opts ...grpc.CallOption) (*UserReply, error) // read user by uid ReadUser(ctx context.Context, in *UserReq, opts ...grpc.CallOption) (*UserReply, error) // update user by user data UpdateUser(ctx context.Context, in *UserReq, opts ...grpc.CallOption) (*UserReply, error) // delete user by uid DeleteUser(ctx context.Context, in *UserReq, opts ...grpc.CallOption) (*UserReply, error) }
UserClient is the client API for User service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
func NewUserClient ¶
func NewUserClient(cc grpc.ClientConnInterface) UserClient
type UserMsg ¶ added in v1.11.0
type UserMsg struct { Uid int64 `protobuf:"zigzag64,1,opt,name=uid,proto3" json:"uid,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Sex int64 `protobuf:"zigzag64,3,opt,name=sex,proto3" json:"sex,omitempty"` // contains filtered or unexported fields }
user message
func (*UserMsg) Descriptor
deprecated
added in
v1.11.0
func (*UserMsg) ProtoMessage ¶ added in v1.11.0
func (*UserMsg) ProtoMessage()
func (*UserMsg) ProtoReflect ¶ added in v1.11.0
func (x *UserMsg) ProtoReflect() protoreflect.Message
type UserReply ¶ added in v1.11.0
type UserReply struct { // 业务错误码 Code int64 `protobuf:"zigzag64,1,opt,name=code,proto3" json:"code,omitempty"` // 业务错误信息 Msg string `protobuf:"bytes,2,opt,name=msg,proto3" json:"msg,omitempty"` // 业务数据 Data *UserMsg `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` // contains filtered or unexported fields }
user reply
func (*UserReply) Descriptor
deprecated
added in
v1.11.0
func (*UserReply) ProtoMessage ¶ added in v1.11.0
func (*UserReply) ProtoMessage()
func (*UserReply) ProtoReflect ¶ added in v1.11.0
func (x *UserReply) ProtoReflect() protoreflect.Message
type UserReq ¶ added in v1.11.0
type UserReq struct { // 业务数据 Data *UserMsg `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` // contains filtered or unexported fields }
user request
func (*UserReq) Descriptor
deprecated
added in
v1.11.0
func (*UserReq) ProtoMessage ¶ added in v1.11.0
func (*UserReq) ProtoMessage()
func (*UserReq) ProtoReflect ¶ added in v1.11.0
func (x *UserReq) ProtoReflect() protoreflect.Message
type UserServer ¶
type UserServer interface { // ping by message Ping(context.Context, *PingReq) (*PingReply, error) // create user by user data CreateUser(context.Context, *UserReq) (*UserReply, error) // read user by uid ReadUser(context.Context, *UserReq) (*UserReply, error) // update user by user data UpdateUser(context.Context, *UserReq) (*UserReply, error) // delete user by uid DeleteUser(context.Context, *UserReq) (*UserReply, error) }
UserServer is the server API for User service. All implementations should embed UnimplementedUserServer for forward compatibility