Documentation
¶
Index ¶
- Variables
- func CheckAuth(ctx context.Context) (username string)
- func CreateToken(userName string) (tokenString string)
- func RegisterPingServer(s *grpc.Server, srv PingServer)
- type AuthToekn
- type Claims
- type LoginReply
- type LoginRequest
- func (*LoginRequest) Descriptor() ([]byte, []int)deprecated
- func (x *LoginRequest) GetPassword() string
- func (x *LoginRequest) GetUsername() string
- func (*LoginRequest) ProtoMessage()
- func (x *LoginRequest) ProtoReflect() protoreflect.Message
- func (x *LoginRequest) Reset()
- func (x *LoginRequest) String() string
- type PingClient
- type PingMessage
- type PingServer
- type Server
- type UnimplementedPingServer
Constants ¶
This section is empty.
Variables ¶
var File_token_proto protoreflect.FileDescriptor
Functions ¶
func CreateToken ¶
func RegisterPingServer ¶
func RegisterPingServer(s *grpc.Server, srv PingServer)
Types ¶
type AuthToekn ¶
type AuthToekn struct {
Token string
}
AuthToekn 自定义认证 实现了credentials.PerRPCCredentials接口
func (AuthToekn) GetRequestMetadata ¶
func (AuthToekn) RequireTransportSecurity ¶
type Claims ¶
type Claims struct { jwt.StandardClaims // Username defines the identity of the user. Username string `json:"username"` }
Claims defines the struct containing the token claims.
type LoginReply ¶
type LoginReply struct { Status string `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` Token string `protobuf:"bytes,2,opt,name=token,proto3" json:"token,omitempty"` // contains filtered or unexported fields }
func (*LoginReply) Descriptor
deprecated
func (*LoginReply) Descriptor() ([]byte, []int)
Deprecated: Use LoginReply.ProtoReflect.Descriptor instead.
func (*LoginReply) GetStatus ¶
func (x *LoginReply) GetStatus() string
func (*LoginReply) GetToken ¶
func (x *LoginReply) GetToken() string
func (*LoginReply) ProtoMessage ¶
func (*LoginReply) ProtoMessage()
func (*LoginReply) ProtoReflect ¶
func (x *LoginReply) ProtoReflect() protoreflect.Message
func (*LoginReply) Reset ¶
func (x *LoginReply) Reset()
func (*LoginReply) String ¶
func (x *LoginReply) String() string
type LoginRequest ¶
type LoginRequest struct { Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` Password string `protobuf:"bytes,2,opt,name=password,proto3" json:"password,omitempty"` // contains filtered or unexported fields }
func (*LoginRequest) Descriptor
deprecated
func (*LoginRequest) Descriptor() ([]byte, []int)
Deprecated: Use LoginRequest.ProtoReflect.Descriptor instead.
func (*LoginRequest) GetPassword ¶
func (x *LoginRequest) GetPassword() string
func (*LoginRequest) GetUsername ¶
func (x *LoginRequest) GetUsername() string
func (*LoginRequest) ProtoMessage ¶
func (*LoginRequest) ProtoMessage()
func (*LoginRequest) ProtoReflect ¶
func (x *LoginRequest) ProtoReflect() protoreflect.Message
func (*LoginRequest) Reset ¶
func (x *LoginRequest) Reset()
func (*LoginRequest) String ¶
func (x *LoginRequest) String() string
type PingClient ¶
type PingClient interface { Login(ctx context.Context, in *LoginRequest, opts ...grpc.CallOption) (*LoginReply, error) SayHello(ctx context.Context, in *PingMessage, opts ...grpc.CallOption) (*PingMessage, error) }
PingClient is the client API for Ping service.
For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream.
func NewPingClient ¶
func NewPingClient(cc grpc.ClientConnInterface) PingClient
type PingMessage ¶
type PingMessage struct { Greeting string `protobuf:"bytes,1,opt,name=greeting,proto3" json:"greeting,omitempty"` // contains filtered or unexported fields }
func (*PingMessage) Descriptor
deprecated
func (*PingMessage) Descriptor() ([]byte, []int)
Deprecated: Use PingMessage.ProtoReflect.Descriptor instead.
func (*PingMessage) GetGreeting ¶
func (x *PingMessage) GetGreeting() string
func (*PingMessage) ProtoMessage ¶
func (*PingMessage) ProtoMessage()
func (*PingMessage) ProtoReflect ¶
func (x *PingMessage) ProtoReflect() protoreflect.Message
func (*PingMessage) Reset ¶
func (x *PingMessage) Reset()
func (*PingMessage) String ¶
func (x *PingMessage) String() string
type PingServer ¶
type PingServer interface { Login(context.Context, *LoginRequest) (*LoginReply, error) SayHello(context.Context, *PingMessage) (*PingMessage, error) }
PingServer is the server API for Ping service.
type Server ¶
type Server struct { }
Server represents the gRPC server
func (*Server) Login ¶
func (s *Server) Login(ctx context.Context, in *LoginRequest) (*LoginReply, error)
func (*Server) SayHello ¶
func (s *Server) SayHello(ctx context.Context, in *PingMessage) (*PingMessage, error)
SayHello generates response to a Ping request
type UnimplementedPingServer ¶
type UnimplementedPingServer struct { }
UnimplementedPingServer can be embedded to have forward compatible implementations.
func (*UnimplementedPingServer) Login ¶
func (*UnimplementedPingServer) Login(context.Context, *LoginRequest) (*LoginReply, error)
func (*UnimplementedPingServer) SayHello ¶
func (*UnimplementedPingServer) SayHello(context.Context, *PingMessage) (*PingMessage, error)