Documentation ¶
Overview ¶
Package example is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func RegisterUserServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserServiceClient) error
- func RegisterUserServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServiceServer) error
- func RegisterUserServiceServer(s *grpc.Server, srv UserServiceServer)
- type ListUsersRequest
- func (*ListUsersRequest) Descriptor() ([]byte, []int)
- func (m *ListUsersRequest) GetCreatedSince() *time.Time
- func (m *ListUsersRequest) GetOlderThan() *time.Duration
- func (m *ListUsersRequest) Marshal() (dAtA []byte, err error)
- func (m *ListUsersRequest) MarshalTo(dAtA []byte) (int, error)
- func (m *ListUsersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*ListUsersRequest) ProtoMessage()
- func (m *ListUsersRequest) Reset()
- func (m *ListUsersRequest) Size() (n int)
- func (m *ListUsersRequest) String() string
- func (m *ListUsersRequest) Unmarshal(dAtA []byte) error
- func (this *ListUsersRequest) Validate() error
- func (m *ListUsersRequest) XXX_DiscardUnknown()
- func (m *ListUsersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *ListUsersRequest) XXX_Merge(src proto.Message)
- func (*ListUsersRequest) XXX_MessageName() string
- func (m *ListUsersRequest) XXX_Size() int
- func (m *ListUsersRequest) XXX_Unmarshal(b []byte) error
- type Role
- type UnimplementedUserServiceServer
- func (*UnimplementedUserServiceServer) AddUser(ctx context.Context, req *User) (*types.Empty, error)
- func (*UnimplementedUserServiceServer) ListUsers(req *ListUsersRequest, srv UserService_ListUsersServer) error
- func (*UnimplementedUserServiceServer) ListUsersByRole(req *UserRole, srv UserService_ListUsersByRoleServer) error
- func (*UnimplementedUserServiceServer) UpdateUser(ctx context.Context, req *UpdateUserRequest) (*User, error)
- type UpdateUserRequest
- func (*UpdateUserRequest) Descriptor() ([]byte, []int)
- func (m *UpdateUserRequest) GetUpdateMask() *types.FieldMask
- func (m *UpdateUserRequest) GetUser() *User
- func (m *UpdateUserRequest) Marshal() (dAtA []byte, err error)
- func (m *UpdateUserRequest) MarshalTo(dAtA []byte) (int, error)
- func (m *UpdateUserRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*UpdateUserRequest) ProtoMessage()
- func (m *UpdateUserRequest) Reset()
- func (m *UpdateUserRequest) Size() (n int)
- func (m *UpdateUserRequest) String() string
- func (m *UpdateUserRequest) Unmarshal(dAtA []byte) error
- func (this *UpdateUserRequest) Validate() error
- func (m *UpdateUserRequest) XXX_DiscardUnknown()
- func (m *UpdateUserRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *UpdateUserRequest) XXX_Merge(src proto.Message)
- func (*UpdateUserRequest) XXX_MessageName() string
- func (m *UpdateUserRequest) XXX_Size() int
- func (m *UpdateUserRequest) XXX_Unmarshal(b []byte) error
- type User
- func (*User) Descriptor() ([]byte, []int)
- func (m *User) GetCreateDate() *time.Time
- func (m *User) GetID() uint32
- func (m *User) GetRole() Role
- func (m *User) Marshal() (dAtA []byte, err error)
- func (m *User) MarshalTo(dAtA []byte) (int, error)
- func (m *User) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*User) ProtoMessage()
- func (m *User) Reset()
- func (m *User) Size() (n int)
- func (m *User) String() string
- func (m *User) Unmarshal(dAtA []byte) error
- func (this *User) Validate() error
- func (m *User) XXX_DiscardUnknown()
- func (m *User) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *User) XXX_Merge(src proto.Message)
- func (*User) XXX_MessageName() string
- func (m *User) XXX_Size() int
- func (m *User) XXX_Unmarshal(b []byte) error
- type UserRole
- func (*UserRole) Descriptor() ([]byte, []int)
- func (m *UserRole) GetRole() Role
- func (m *UserRole) Marshal() (dAtA []byte, err error)
- func (m *UserRole) MarshalTo(dAtA []byte) (int, error)
- func (m *UserRole) MarshalToSizedBuffer(dAtA []byte) (int, error)
- func (*UserRole) ProtoMessage()
- func (m *UserRole) Reset()
- func (m *UserRole) Size() (n int)
- func (m *UserRole) String() string
- func (m *UserRole) Unmarshal(dAtA []byte) error
- func (this *UserRole) Validate() error
- func (m *UserRole) XXX_DiscardUnknown()
- func (m *UserRole) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
- func (m *UserRole) XXX_Merge(src proto.Message)
- func (*UserRole) XXX_MessageName() string
- func (m *UserRole) XXX_Size() int
- func (m *UserRole) XXX_Unmarshal(b []byte) error
- type UserServiceClient
- type UserServiceServer
- type UserService_ListUsersByRoleClient
- type UserService_ListUsersByRoleServer
- type UserService_ListUsersClient
- type UserService_ListUsersServer
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidLengthExample = fmt.Errorf("proto: negative length found during unmarshaling") ErrIntOverflowExample = fmt.Errorf("proto: integer overflow") ErrUnexpectedEndOfGroupExample = fmt.Errorf("proto: unexpected end of group") )
var Role_name = map[int32]string{
0: "GUEST",
1: "MEMBER",
2: "ADMIN",
}
var Role_value = map[string]int32{
"GUEST": 0,
"MEMBER": 1,
"ADMIN": 2,
}
Functions ¶
func RegisterUserServiceHandler ¶
func RegisterUserServiceHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
RegisterUserServiceHandler registers the http handlers for service UserService to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterUserServiceHandlerClient ¶
func RegisterUserServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux, client UserServiceClient) error
RegisterUserServiceHandlerClient registers the http handlers for service UserService to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "UserServiceClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "UserServiceClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "UserServiceClient" to call the correct interceptors.
func RegisterUserServiceHandlerFromEndpoint ¶
func RegisterUserServiceHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterUserServiceHandlerFromEndpoint is same as RegisterUserServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterUserServiceHandlerServer ¶
func RegisterUserServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux, server UserServiceServer) error
RegisterUserServiceHandlerServer registers the http handlers for service UserService to "mux". UnaryRPC :call UserServiceServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
func RegisterUserServiceServer ¶
func RegisterUserServiceServer(s *grpc.Server, srv UserServiceServer)
Types ¶
type ListUsersRequest ¶
type ListUsersRequest struct { // Only list users created after this timestamp CreatedSince *time.Time `protobuf:"bytes,1,opt,name=created_since,json=createdSince,proto3,stdtime" json:"created_since,omitempty"` // Only list users older than this Duration OlderThan *time.Duration `protobuf:"bytes,2,opt,name=older_than,json=olderThan,proto3,stdduration" json:"older_than,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*ListUsersRequest) Descriptor ¶
func (*ListUsersRequest) Descriptor() ([]byte, []int)
func (*ListUsersRequest) GetCreatedSince ¶
func (m *ListUsersRequest) GetCreatedSince() *time.Time
func (*ListUsersRequest) GetOlderThan ¶
func (m *ListUsersRequest) GetOlderThan() *time.Duration
func (*ListUsersRequest) Marshal ¶
func (m *ListUsersRequest) Marshal() (dAtA []byte, err error)
func (*ListUsersRequest) MarshalToSizedBuffer ¶
func (m *ListUsersRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*ListUsersRequest) ProtoMessage ¶
func (*ListUsersRequest) ProtoMessage()
func (*ListUsersRequest) Reset ¶
func (m *ListUsersRequest) Reset()
func (*ListUsersRequest) Size ¶
func (m *ListUsersRequest) Size() (n int)
func (*ListUsersRequest) String ¶
func (m *ListUsersRequest) String() string
func (*ListUsersRequest) Unmarshal ¶
func (m *ListUsersRequest) Unmarshal(dAtA []byte) error
func (*ListUsersRequest) Validate ¶
func (this *ListUsersRequest) Validate() error
func (*ListUsersRequest) XXX_DiscardUnknown ¶
func (m *ListUsersRequest) XXX_DiscardUnknown()
func (*ListUsersRequest) XXX_Marshal ¶
func (m *ListUsersRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*ListUsersRequest) XXX_Merge ¶
func (m *ListUsersRequest) XXX_Merge(src proto.Message)
func (*ListUsersRequest) XXX_MessageName ¶
func (*ListUsersRequest) XXX_MessageName() string
func (*ListUsersRequest) XXX_Size ¶
func (m *ListUsersRequest) XXX_Size() int
func (*ListUsersRequest) XXX_Unmarshal ¶
func (m *ListUsersRequest) XXX_Unmarshal(b []byte) error
type UnimplementedUserServiceServer ¶
type UnimplementedUserServiceServer struct { }
UnimplementedUserServiceServer can be embedded to have forward compatible implementations.
func (*UnimplementedUserServiceServer) ListUsers ¶
func (*UnimplementedUserServiceServer) ListUsers(req *ListUsersRequest, srv UserService_ListUsersServer) error
func (*UnimplementedUserServiceServer) ListUsersByRole ¶
func (*UnimplementedUserServiceServer) ListUsersByRole(req *UserRole, srv UserService_ListUsersByRoleServer) error
func (*UnimplementedUserServiceServer) UpdateUser ¶
func (*UnimplementedUserServiceServer) UpdateUser(ctx context.Context, req *UpdateUserRequest) (*User, error)
type UpdateUserRequest ¶
type UpdateUserRequest struct { // The user resource which replaces the resource on the server. User *User `protobuf:"bytes,1,opt,name=user,proto3" json:"user,omitempty"` // The update mask applies to the resource. For the `FieldMask` definition, // see https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#fieldmask UpdateMask *types.FieldMask `protobuf:"bytes,2,opt,name=update_mask,json=updateMask,proto3" json:"update_mask,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*UpdateUserRequest) Descriptor ¶
func (*UpdateUserRequest) Descriptor() ([]byte, []int)
func (*UpdateUserRequest) GetUpdateMask ¶
func (m *UpdateUserRequest) GetUpdateMask() *types.FieldMask
func (*UpdateUserRequest) GetUser ¶
func (m *UpdateUserRequest) GetUser() *User
func (*UpdateUserRequest) Marshal ¶
func (m *UpdateUserRequest) Marshal() (dAtA []byte, err error)
func (*UpdateUserRequest) MarshalTo ¶
func (m *UpdateUserRequest) MarshalTo(dAtA []byte) (int, error)
func (*UpdateUserRequest) MarshalToSizedBuffer ¶
func (m *UpdateUserRequest) MarshalToSizedBuffer(dAtA []byte) (int, error)
func (*UpdateUserRequest) ProtoMessage ¶
func (*UpdateUserRequest) ProtoMessage()
func (*UpdateUserRequest) Reset ¶
func (m *UpdateUserRequest) Reset()
func (*UpdateUserRequest) Size ¶
func (m *UpdateUserRequest) Size() (n int)
func (*UpdateUserRequest) String ¶
func (m *UpdateUserRequest) String() string
func (*UpdateUserRequest) Unmarshal ¶
func (m *UpdateUserRequest) Unmarshal(dAtA []byte) error
func (*UpdateUserRequest) Validate ¶
func (this *UpdateUserRequest) Validate() error
func (*UpdateUserRequest) XXX_DiscardUnknown ¶
func (m *UpdateUserRequest) XXX_DiscardUnknown()
func (*UpdateUserRequest) XXX_Marshal ¶
func (m *UpdateUserRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)
func (*UpdateUserRequest) XXX_Merge ¶
func (m *UpdateUserRequest) XXX_Merge(src proto.Message)
func (*UpdateUserRequest) XXX_MessageName ¶
func (*UpdateUserRequest) XXX_MessageName() string
func (*UpdateUserRequest) XXX_Size ¶
func (m *UpdateUserRequest) XXX_Size() int
func (*UpdateUserRequest) XXX_Unmarshal ¶
func (m *UpdateUserRequest) XXX_Unmarshal(b []byte) error
type User ¶
type User struct { ID uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` Role Role `protobuf:"varint,2,opt,name=role,proto3,enum=example.Role" json:"role,omitempty"` CreateDate *time.Time `protobuf:"bytes,3,opt,name=create_date,json=createDate,proto3,stdtime" json:"create_date,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*User) Descriptor ¶
func (*User) GetCreateDate ¶
func (*User) ProtoMessage ¶
func (*User) ProtoMessage()
func (*User) XXX_DiscardUnknown ¶
func (m *User) XXX_DiscardUnknown()
func (*User) XXX_MessageName ¶
func (*User) XXX_Unmarshal ¶
type UserRole ¶
type UserRole struct { Role Role `protobuf:"varint,1,opt,name=role,proto3,enum=example.Role" json:"role,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` }
func (*UserRole) Descriptor ¶
func (*UserRole) MarshalToSizedBuffer ¶
func (*UserRole) ProtoMessage ¶
func (*UserRole) ProtoMessage()
func (*UserRole) XXX_DiscardUnknown ¶
func (m *UserRole) XXX_DiscardUnknown()
func (*UserRole) XXX_Marshal ¶
func (*UserRole) XXX_MessageName ¶
func (*UserRole) XXX_Unmarshal ¶
type UserServiceClient ¶
type UserServiceClient interface { AddUser(ctx context.Context, in *User, opts ...grpc.CallOption) (*types.Empty, error) ListUsers(ctx context.Context, in *ListUsersRequest, opts ...grpc.CallOption) (UserService_ListUsersClient, error) ListUsersByRole(ctx context.Context, in *UserRole, opts ...grpc.CallOption) (UserService_ListUsersByRoleClient, error) UpdateUser(ctx context.Context, in *UpdateUserRequest, opts ...grpc.CallOption) (*User, error) }
UserServiceClient is the client API for UserService service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewUserServiceClient ¶
func NewUserServiceClient(cc *grpc.ClientConn) UserServiceClient
type UserServiceServer ¶
type UserServiceServer interface { AddUser(context.Context, *User) (*types.Empty, error) ListUsers(*ListUsersRequest, UserService_ListUsersServer) error ListUsersByRole(*UserRole, UserService_ListUsersByRoleServer) error UpdateUser(context.Context, *UpdateUserRequest) (*User, error) }
UserServiceServer is the server API for UserService service.
type UserService_ListUsersByRoleClient ¶
type UserService_ListUsersByRoleClient interface { Recv() (*User, error) grpc.ClientStream }
type UserService_ListUsersByRoleServer ¶
type UserService_ListUsersByRoleServer interface { Send(*User) error grpc.ServerStream }
type UserService_ListUsersClient ¶
type UserService_ListUsersClient interface { Recv() (*User, error) grpc.ClientStream }
type UserService_ListUsersServer ¶
type UserService_ListUsersServer interface { Send(*User) error grpc.ServerStream }