Documentation ¶
Overview ¶
Package v1 is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Constants
- 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 CreateUserRequest
- func (*CreateUserRequest) Descriptor() ([]byte, []int)deprecated
- func (x *CreateUserRequest) GetAddress() string
- func (x *CreateUserRequest) GetEmail() string
- func (x *CreateUserRequest) GetName() string
- func (x *CreateUserRequest) GetPhone() string
- func (*CreateUserRequest) ProtoMessage()
- func (x *CreateUserRequest) ProtoReflect() protoreflect.Message
- func (x *CreateUserRequest) Reset()
- func (x *CreateUserRequest) String() string
- type CreateUserResponse
- func (*CreateUserResponse) Descriptor() ([]byte, []int)deprecated
- func (x *CreateUserResponse) GetUserId() int64
- func (*CreateUserResponse) ProtoMessage()
- func (x *CreateUserResponse) ProtoReflect() protoreflect.Message
- func (x *CreateUserResponse) Reset()
- func (x *CreateUserResponse) String() string
- type GetUserRequest
- type GetUserResponse
- func (*GetUserResponse) Descriptor() ([]byte, []int)deprecated
- func (x *GetUserResponse) GetAddress() string
- func (x *GetUserResponse) GetEmail() string
- func (x *GetUserResponse) GetName() string
- func (x *GetUserResponse) GetPhone() string
- func (x *GetUserResponse) GetUserId() int64
- func (*GetUserResponse) ProtoMessage()
- func (x *GetUserResponse) ProtoReflect() protoreflect.Message
- func (x *GetUserResponse) Reset()
- func (x *GetUserResponse) String() string
- type UnimplementedUserServer
- type UnsafeUserServer
- type UserClient
- type UserServer
Constants ¶
const ( User_Create_FullMethodName = "/user.v1.User/Create" User_Get_FullMethodName = "/user.v1.User/Get" )
Variables ¶
var File_user_v1_user_proto protoreflect.FileDescriptor
var User_ServiceDesc = grpc.ServiceDesc{ ServiceName: "user.v1.User", HandlerType: (*UserServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Create", Handler: _User_Create_Handler, }, { MethodName: "Get", Handler: _User_Get_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "user/v1/user.proto", }
User_ServiceDesc is the grpc.ServiceDesc for User service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)
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. This client ignores the HTTP middlewares.
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. GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
func RegisterUserServer ¶ added in v0.0.14
func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer)
Types ¶
type CreateUserRequest ¶
type CreateUserRequest struct { Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` Phone string `protobuf:"bytes,3,opt,name=phone,proto3" json:"phone,omitempty"` Address string `protobuf:"bytes,4,opt,name=address,proto3" json:"address,omitempty"` // contains filtered or unexported fields }
func (*CreateUserRequest) Descriptor
deprecated
func (*CreateUserRequest) Descriptor() ([]byte, []int)
Deprecated: Use CreateUserRequest.ProtoReflect.Descriptor instead.
func (*CreateUserRequest) GetAddress ¶
func (x *CreateUserRequest) GetAddress() string
func (*CreateUserRequest) GetEmail ¶
func (x *CreateUserRequest) GetEmail() string
func (*CreateUserRequest) GetName ¶
func (x *CreateUserRequest) GetName() string
func (*CreateUserRequest) GetPhone ¶
func (x *CreateUserRequest) GetPhone() string
func (*CreateUserRequest) ProtoMessage ¶
func (*CreateUserRequest) ProtoMessage()
func (*CreateUserRequest) ProtoReflect ¶ added in v0.0.15
func (x *CreateUserRequest) ProtoReflect() protoreflect.Message
func (*CreateUserRequest) Reset ¶
func (x *CreateUserRequest) Reset()
func (*CreateUserRequest) String ¶
func (x *CreateUserRequest) String() string
type CreateUserResponse ¶
type CreateUserResponse struct { UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // contains filtered or unexported fields }
func (*CreateUserResponse) Descriptor
deprecated
func (*CreateUserResponse) Descriptor() ([]byte, []int)
Deprecated: Use CreateUserResponse.ProtoReflect.Descriptor instead.
func (*CreateUserResponse) GetUserId ¶
func (x *CreateUserResponse) GetUserId() int64
func (*CreateUserResponse) ProtoMessage ¶
func (*CreateUserResponse) ProtoMessage()
func (*CreateUserResponse) ProtoReflect ¶ added in v0.0.15
func (x *CreateUserResponse) ProtoReflect() protoreflect.Message
func (*CreateUserResponse) Reset ¶
func (x *CreateUserResponse) Reset()
func (*CreateUserResponse) String ¶
func (x *CreateUserResponse) String() string
type GetUserRequest ¶
type GetUserRequest struct { UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` // contains filtered or unexported fields }
func (*GetUserRequest) Descriptor
deprecated
func (*GetUserRequest) Descriptor() ([]byte, []int)
Deprecated: Use GetUserRequest.ProtoReflect.Descriptor instead.
func (*GetUserRequest) GetUserId ¶
func (x *GetUserRequest) GetUserId() int64
func (*GetUserRequest) ProtoMessage ¶
func (*GetUserRequest) ProtoMessage()
func (*GetUserRequest) ProtoReflect ¶ added in v0.0.15
func (x *GetUserRequest) ProtoReflect() protoreflect.Message
func (*GetUserRequest) Reset ¶
func (x *GetUserRequest) Reset()
func (*GetUserRequest) String ¶
func (x *GetUserRequest) String() string
type GetUserResponse ¶
type GetUserResponse struct { UserId int64 `protobuf:"varint,1,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` Email string `protobuf:"bytes,3,opt,name=email,proto3" json:"email,omitempty"` Phone string `protobuf:"bytes,4,opt,name=phone,proto3" json:"phone,omitempty"` Address string `protobuf:"bytes,5,opt,name=address,proto3" json:"address,omitempty"` // contains filtered or unexported fields }
func (*GetUserResponse) Descriptor
deprecated
func (*GetUserResponse) Descriptor() ([]byte, []int)
Deprecated: Use GetUserResponse.ProtoReflect.Descriptor instead.
func (*GetUserResponse) GetAddress ¶
func (x *GetUserResponse) GetAddress() string
func (*GetUserResponse) GetEmail ¶
func (x *GetUserResponse) GetEmail() string
func (*GetUserResponse) GetName ¶
func (x *GetUserResponse) GetName() string
func (*GetUserResponse) GetPhone ¶
func (x *GetUserResponse) GetPhone() string
func (*GetUserResponse) GetUserId ¶
func (x *GetUserResponse) GetUserId() int64
func (*GetUserResponse) ProtoMessage ¶
func (*GetUserResponse) ProtoMessage()
func (*GetUserResponse) ProtoReflect ¶ added in v0.0.15
func (x *GetUserResponse) ProtoReflect() protoreflect.Message
func (*GetUserResponse) Reset ¶
func (x *GetUserResponse) Reset()
func (*GetUserResponse) String ¶
func (x *GetUserResponse) String() string
type UnimplementedUserServer ¶ added in v0.0.14
type UnimplementedUserServer struct{}
UnimplementedUserServer must be embedded to have forward compatible implementations.
NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.
func (UnimplementedUserServer) Create ¶ added in v0.0.14
func (UnimplementedUserServer) Create(context.Context, *CreateUserRequest) (*CreateUserResponse, error)
func (UnimplementedUserServer) Get ¶ added in v0.0.14
func (UnimplementedUserServer) Get(context.Context, *GetUserRequest) (*GetUserResponse, error)
type UnsafeUserServer ¶ added in v0.0.14
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 ¶ added in v0.0.14
type UserClient interface { Create(ctx context.Context, in *CreateUserRequest, opts ...grpc.CallOption) (*CreateUserResponse, error) Get(ctx context.Context, in *GetUserRequest, opts ...grpc.CallOption) (*GetUserResponse, 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 ¶ added in v0.0.14
func NewUserClient(cc grpc.ClientConnInterface) UserClient
type UserServer ¶ added in v0.0.14
type UserServer interface { Create(context.Context, *CreateUserRequest) (*CreateUserResponse, error) Get(context.Context, *GetUserRequest) (*GetUserResponse, error) // contains filtered or unexported methods }
UserServer is the server API for User service. All implementations must embed UnimplementedUserServer for forward compatibility.