Documentation ¶
Overview ¶
Package user 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 Auth
- func (*Auth) Descriptor() ([]byte, []int)deprecated
- func (x *Auth) GetExpire() int64
- func (x *Auth) GetToken() string
- func (*Auth) ProtoMessage()
- func (x *Auth) ProtoReflect() protoreflect.Message
- func (x *Auth) Reset()
- func (x *Auth) String() string
- func (m *Auth) Validate() error
- func (m *Auth) ValidateAll() error
- type AuthMultiError
- type AuthValidationError
- type LoginReq
- func (*LoginReq) Descriptor() ([]byte, []int)deprecated
- func (x *LoginReq) GetAccount() string
- func (x *LoginReq) GetCaptcha() string
- func (x *LoginReq) GetCaptchaId() string
- func (x *LoginReq) GetPassword() string
- func (x *LoginReq) GetType() LoginType
- func (*LoginReq) ProtoMessage()
- func (x *LoginReq) ProtoReflect() protoreflect.Message
- func (x *LoginReq) Reset()
- func (x *LoginReq) String() string
- func (m *LoginReq) Validate() error
- func (m *LoginReq) ValidateAll() error
- type LoginReqMultiError
- type LoginReqValidationError
- type LoginType
- type RegisterReq
- func (*RegisterReq) Descriptor() ([]byte, []int)deprecated
- func (x *RegisterReq) GetConfirmPassword() string
- func (x *RegisterReq) GetEmail() string
- func (x *RegisterReq) GetImgCache() string
- func (x *RegisterReq) GetPassword() string
- func (x *RegisterReq) GetUsername() string
- func (*RegisterReq) ProtoMessage()
- func (x *RegisterReq) ProtoReflect() protoreflect.Message
- func (x *RegisterReq) Reset()
- func (x *RegisterReq) String() string
- func (m *RegisterReq) Validate() error
- func (m *RegisterReq) ValidateAll() error
- type RegisterReqMultiError
- type RegisterReqValidationError
- func (e RegisterReqValidationError) Cause() error
- func (e RegisterReqValidationError) Error() string
- func (e RegisterReqValidationError) ErrorName() string
- func (e RegisterReqValidationError) Field() string
- func (e RegisterReqValidationError) Key() bool
- func (e RegisterReqValidationError) Reason() string
- type UnimplementedUserServer
- type UnsafeUserServer
- type UserAuthRes
- func (*UserAuthRes) Descriptor() ([]byte, []int)deprecated
- func (x *UserAuthRes) GetTokenInfo() *Auth
- func (*UserAuthRes) ProtoMessage()
- func (x *UserAuthRes) ProtoReflect() protoreflect.Message
- func (x *UserAuthRes) Reset()
- func (x *UserAuthRes) String() string
- func (m *UserAuthRes) Validate() error
- func (m *UserAuthRes) ValidateAll() error
- type UserAuthResMultiError
- type UserAuthResValidationError
- func (e UserAuthResValidationError) Cause() error
- func (e UserAuthResValidationError) Error() string
- func (e UserAuthResValidationError) ErrorName() string
- func (e UserAuthResValidationError) Field() string
- func (e UserAuthResValidationError) Key() bool
- func (e UserAuthResValidationError) Reason() string
- type UserClient
- type UserInfo
- func (*UserInfo) Descriptor() ([]byte, []int)deprecated
- func (x *UserInfo) GetAccount() string
- func (x *UserInfo) GetMobile() string
- func (x *UserInfo) GetNickname() string
- func (*UserInfo) ProtoMessage()
- func (x *UserInfo) ProtoReflect() protoreflect.Message
- func (x *UserInfo) Reset()
- func (x *UserInfo) String() string
- func (m *UserInfo) Validate() error
- func (m *UserInfo) ValidateAll() error
- type UserInfoMultiError
- type UserInfoValidationError
- type UserServer
Constants ¶
const ( User_Register_FullMethodName = "/user.v1.User/Register" User_Login_FullMethodName = "/user.v1.User/Login" )
Variables ¶
var ( LoginType_name = map[int32]string{ 0: "Detault_Login", 1: "Mobile_Login", } LoginType_value = map[string]int32{ "Detault_Login": 0, "Mobile_Login": 1, } )
Enum value maps for LoginType.
var File_user_token_proto protoreflect.FileDescriptor
var File_user_user_proto protoreflect.FileDescriptor
var User_ServiceDesc = grpc.ServiceDesc{ ServiceName: "user.v1.User", HandlerType: (*UserServer)(nil), Methods: []grpc.MethodDesc{ { MethodName: "Register", Handler: _User_Register_Handler, }, { MethodName: "Login", Handler: _User_Login_Handler, }, }, Streams: []grpc.StreamDesc{}, Metadata: "user/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 ¶
func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer)
Types ¶
type Auth ¶
type Auth struct { Token string `protobuf:"bytes,1,opt,name=token,proto3" json:"token,omitempty"` // 认证token Expire int64 `protobuf:"varint,2,opt,name=expire,proto3" json:"expire,omitempty"` // 认证过期时间 // contains filtered or unexported fields }
token 信息
func (*Auth) Descriptor
deprecated
func (*Auth) ProtoMessage ¶
func (*Auth) ProtoMessage()
func (*Auth) ProtoReflect ¶
func (x *Auth) ProtoReflect() protoreflect.Message
func (*Auth) Validate ¶
Validate checks the field values on Auth with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*Auth) ValidateAll ¶
ValidateAll checks the field values on Auth with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in AuthMultiError, or nil if none found.
type AuthMultiError ¶
type AuthMultiError []error
AuthMultiError is an error wrapping multiple validation errors returned by Auth.ValidateAll() if the designated constraints aren't met.
func (AuthMultiError) AllErrors ¶
func (m AuthMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (AuthMultiError) Error ¶
func (m AuthMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type AuthValidationError ¶
type AuthValidationError struct {
// contains filtered or unexported fields
}
AuthValidationError is the validation error returned by Auth.Validate if the designated constraints aren't met.
func (AuthValidationError) Cause ¶
func (e AuthValidationError) Cause() error
Cause function returns cause value.
func (AuthValidationError) Error ¶
func (e AuthValidationError) Error() string
Error satisfies the builtin error interface
func (AuthValidationError) ErrorName ¶
func (e AuthValidationError) ErrorName() string
ErrorName returns error name.
func (AuthValidationError) Field ¶
func (e AuthValidationError) Field() string
Field function returns field value.
func (AuthValidationError) Key ¶
func (e AuthValidationError) Key() bool
Key function returns key value.
func (AuthValidationError) Reason ¶
func (e AuthValidationError) Reason() string
Reason function returns reason value.
type LoginReq ¶
type LoginReq struct { Type LoginType `protobuf:"varint,1,opt,name=type,proto3,enum=user.v1.LoginType" json:"type,omitempty"` // 登录类型 Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"` // 账号 Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` // 认证密码 Captcha string `protobuf:"bytes,4,opt,name=captcha,proto3" json:"captcha,omitempty"` // 验证码 CaptchaId string `protobuf:"bytes,5,opt,name=captcha_id,json=captchaId,proto3" json:"captcha_id,omitempty"` // 验证码id // contains filtered or unexported fields }
登录请求
func (*LoginReq) Descriptor
deprecated
func (*LoginReq) GetAccount ¶
func (*LoginReq) GetCaptcha ¶
func (*LoginReq) GetCaptchaId ¶
func (*LoginReq) GetPassword ¶
func (*LoginReq) ProtoMessage ¶
func (*LoginReq) ProtoMessage()
func (*LoginReq) ProtoReflect ¶
func (x *LoginReq) ProtoReflect() protoreflect.Message
func (*LoginReq) Validate ¶
Validate checks the field values on LoginReq with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*LoginReq) ValidateAll ¶
ValidateAll checks the field values on LoginReq with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in LoginReqMultiError, or nil if none found.
type LoginReqMultiError ¶
type LoginReqMultiError []error
LoginReqMultiError is an error wrapping multiple validation errors returned by LoginReq.ValidateAll() if the designated constraints aren't met.
func (LoginReqMultiError) AllErrors ¶
func (m LoginReqMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (LoginReqMultiError) Error ¶
func (m LoginReqMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type LoginReqValidationError ¶
type LoginReqValidationError struct {
// contains filtered or unexported fields
}
LoginReqValidationError is the validation error returned by LoginReq.Validate if the designated constraints aren't met.
func (LoginReqValidationError) Cause ¶
func (e LoginReqValidationError) Cause() error
Cause function returns cause value.
func (LoginReqValidationError) Error ¶
func (e LoginReqValidationError) Error() string
Error satisfies the builtin error interface
func (LoginReqValidationError) ErrorName ¶
func (e LoginReqValidationError) ErrorName() string
ErrorName returns error name.
func (LoginReqValidationError) Field ¶
func (e LoginReqValidationError) Field() string
Field function returns field value.
func (LoginReqValidationError) Key ¶
func (e LoginReqValidationError) Key() bool
Key function returns key value.
func (LoginReqValidationError) Reason ¶
func (e LoginReqValidationError) Reason() string
Reason function returns reason value.
type LoginType ¶
type LoginType int32
登录类型
func (LoginType) Descriptor ¶
func (LoginType) Descriptor() protoreflect.EnumDescriptor
func (LoginType) EnumDescriptor
deprecated
func (LoginType) Number ¶
func (x LoginType) Number() protoreflect.EnumNumber
func (LoginType) Type ¶
func (LoginType) Type() protoreflect.EnumType
type RegisterReq ¶
type RegisterReq struct { Password string `protobuf:"bytes,3,opt,name=password,proto3" json:"password,omitempty"` // 密码 Username string `protobuf:"bytes,1,opt,name=username,proto3" json:"username,omitempty"` // 用户名 Email string `protobuf:"bytes,2,opt,name=email,proto3" json:"email,omitempty"` // 邮箱 ConfirmPassword string `protobuf:"bytes,4,opt,name=confirm_password,json=confirmPassword,proto3" json:"confirm_password,omitempty"` // 确认密码 ImgCache string `protobuf:"bytes,7,opt,name=img_cache,json=imgCache,proto3" json:"img_cache,omitempty"` // 图形验证码 // contains filtered or unexported fields }
注册请求
func (*RegisterReq) Descriptor
deprecated
func (*RegisterReq) Descriptor() ([]byte, []int)
Deprecated: Use RegisterReq.ProtoReflect.Descriptor instead.
func (*RegisterReq) GetConfirmPassword ¶
func (x *RegisterReq) GetConfirmPassword() string
func (*RegisterReq) GetEmail ¶
func (x *RegisterReq) GetEmail() string
func (*RegisterReq) GetImgCache ¶
func (x *RegisterReq) GetImgCache() string
func (*RegisterReq) GetPassword ¶
func (x *RegisterReq) GetPassword() string
func (*RegisterReq) GetUsername ¶
func (x *RegisterReq) GetUsername() string
func (*RegisterReq) ProtoMessage ¶
func (*RegisterReq) ProtoMessage()
func (*RegisterReq) ProtoReflect ¶
func (x *RegisterReq) ProtoReflect() protoreflect.Message
func (*RegisterReq) Reset ¶
func (x *RegisterReq) Reset()
func (*RegisterReq) String ¶
func (x *RegisterReq) String() string
func (*RegisterReq) Validate ¶
func (m *RegisterReq) Validate() error
Validate checks the field values on RegisterReq with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*RegisterReq) ValidateAll ¶
func (m *RegisterReq) ValidateAll() error
ValidateAll checks the field values on RegisterReq with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in RegisterReqMultiError, or nil if none found.
type RegisterReqMultiError ¶
type RegisterReqMultiError []error
RegisterReqMultiError is an error wrapping multiple validation errors returned by RegisterReq.ValidateAll() if the designated constraints aren't met.
func (RegisterReqMultiError) AllErrors ¶
func (m RegisterReqMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (RegisterReqMultiError) Error ¶
func (m RegisterReqMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type RegisterReqValidationError ¶
type RegisterReqValidationError struct {
// contains filtered or unexported fields
}
RegisterReqValidationError is the validation error returned by RegisterReq.Validate if the designated constraints aren't met.
func (RegisterReqValidationError) Cause ¶
func (e RegisterReqValidationError) Cause() error
Cause function returns cause value.
func (RegisterReqValidationError) Error ¶
func (e RegisterReqValidationError) Error() string
Error satisfies the builtin error interface
func (RegisterReqValidationError) ErrorName ¶
func (e RegisterReqValidationError) ErrorName() string
ErrorName returns error name.
func (RegisterReqValidationError) Field ¶
func (e RegisterReqValidationError) Field() string
Field function returns field value.
func (RegisterReqValidationError) Key ¶
func (e RegisterReqValidationError) Key() bool
Key function returns key value.
func (RegisterReqValidationError) Reason ¶
func (e RegisterReqValidationError) Reason() string
Reason function returns reason value.
type UnimplementedUserServer ¶
type UnimplementedUserServer struct{}
UnimplementedUserServer should 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) Login ¶
func (UnimplementedUserServer) Login(context.Context, *LoginReq) (*UserAuthRes, error)
func (UnimplementedUserServer) Register ¶
func (UnimplementedUserServer) Register(context.Context, *RegisterReq) (*UserAuthRes, error)
type UnsafeUserServer ¶
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 UserAuthRes ¶
type UserAuthRes struct { TokenInfo *Auth `protobuf:"bytes,1,opt,name=token_info,json=tokenInfo,proto3" json:"token_info,omitempty"` // token认证信息 // contains filtered or unexported fields }
登录注册返回信息
func (*UserAuthRes) Descriptor
deprecated
func (*UserAuthRes) Descriptor() ([]byte, []int)
Deprecated: Use UserAuthRes.ProtoReflect.Descriptor instead.
func (*UserAuthRes) GetTokenInfo ¶
func (x *UserAuthRes) GetTokenInfo() *Auth
func (*UserAuthRes) ProtoMessage ¶
func (*UserAuthRes) ProtoMessage()
func (*UserAuthRes) ProtoReflect ¶
func (x *UserAuthRes) ProtoReflect() protoreflect.Message
func (*UserAuthRes) Reset ¶
func (x *UserAuthRes) Reset()
func (*UserAuthRes) String ¶
func (x *UserAuthRes) String() string
func (*UserAuthRes) Validate ¶
func (m *UserAuthRes) Validate() error
Validate checks the field values on UserAuthRes with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*UserAuthRes) ValidateAll ¶
func (m *UserAuthRes) ValidateAll() error
ValidateAll checks the field values on UserAuthRes with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in UserAuthResMultiError, or nil if none found.
type UserAuthResMultiError ¶
type UserAuthResMultiError []error
UserAuthResMultiError is an error wrapping multiple validation errors returned by UserAuthRes.ValidateAll() if the designated constraints aren't met.
func (UserAuthResMultiError) AllErrors ¶
func (m UserAuthResMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (UserAuthResMultiError) Error ¶
func (m UserAuthResMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type UserAuthResValidationError ¶
type UserAuthResValidationError struct {
// contains filtered or unexported fields
}
UserAuthResValidationError is the validation error returned by UserAuthRes.Validate if the designated constraints aren't met.
func (UserAuthResValidationError) Cause ¶
func (e UserAuthResValidationError) Cause() error
Cause function returns cause value.
func (UserAuthResValidationError) Error ¶
func (e UserAuthResValidationError) Error() string
Error satisfies the builtin error interface
func (UserAuthResValidationError) ErrorName ¶
func (e UserAuthResValidationError) ErrorName() string
ErrorName returns error name.
func (UserAuthResValidationError) Field ¶
func (e UserAuthResValidationError) Field() string
Field function returns field value.
func (UserAuthResValidationError) Key ¶
func (e UserAuthResValidationError) Key() bool
Key function returns key value.
func (UserAuthResValidationError) Reason ¶
func (e UserAuthResValidationError) Reason() string
Reason function returns reason value.
type UserClient ¶
type UserClient interface { Register(ctx context.Context, in *RegisterReq, opts ...grpc.CallOption) (*UserAuthRes, error) // Login 用户登录 Login(ctx context.Context, in *LoginReq, opts ...grpc.CallOption) (*UserAuthRes, 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.
User 用户管理
func NewUserClient ¶
func NewUserClient(cc grpc.ClientConnInterface) UserClient
type UserInfo ¶
type UserInfo struct { Account string `protobuf:"bytes,1,opt,name=account,proto3" json:"account,omitempty"` // 用户账号 Nickname string `protobuf:"bytes,2,opt,name=nickname,proto3" json:"nickname,omitempty"` // 用户昵称 Mobile string `protobuf:"bytes,3,opt,name=mobile,proto3" json:"mobile,omitempty"` // contains filtered or unexported fields }
用户信息
func (*UserInfo) Descriptor
deprecated
func (*UserInfo) GetAccount ¶
func (*UserInfo) GetNickname ¶
func (*UserInfo) ProtoMessage ¶
func (*UserInfo) ProtoMessage()
func (*UserInfo) ProtoReflect ¶
func (x *UserInfo) ProtoReflect() protoreflect.Message
func (*UserInfo) Validate ¶
Validate checks the field values on UserInfo with the rules defined in the proto definition for this message. If any rules are violated, the first error encountered is returned, or nil if there are no violations.
func (*UserInfo) ValidateAll ¶
ValidateAll checks the field values on UserInfo with the rules defined in the proto definition for this message. If any rules are violated, the result is a list of violation errors wrapped in UserInfoMultiError, or nil if none found.
type UserInfoMultiError ¶
type UserInfoMultiError []error
UserInfoMultiError is an error wrapping multiple validation errors returned by UserInfo.ValidateAll() if the designated constraints aren't met.
func (UserInfoMultiError) AllErrors ¶
func (m UserInfoMultiError) AllErrors() []error
AllErrors returns a list of validation violation errors.
func (UserInfoMultiError) Error ¶
func (m UserInfoMultiError) Error() string
Error returns a concatenation of all the error messages it wraps.
type UserInfoValidationError ¶
type UserInfoValidationError struct {
// contains filtered or unexported fields
}
UserInfoValidationError is the validation error returned by UserInfo.Validate if the designated constraints aren't met.
func (UserInfoValidationError) Cause ¶
func (e UserInfoValidationError) Cause() error
Cause function returns cause value.
func (UserInfoValidationError) Error ¶
func (e UserInfoValidationError) Error() string
Error satisfies the builtin error interface
func (UserInfoValidationError) ErrorName ¶
func (e UserInfoValidationError) ErrorName() string
ErrorName returns error name.
func (UserInfoValidationError) Field ¶
func (e UserInfoValidationError) Field() string
Field function returns field value.
func (UserInfoValidationError) Key ¶
func (e UserInfoValidationError) Key() bool
Key function returns key value.
func (UserInfoValidationError) Reason ¶
func (e UserInfoValidationError) Reason() string
Reason function returns reason value.
type UserServer ¶
type UserServer interface { Register(context.Context, *RegisterReq) (*UserAuthRes, error) // Login 用户登录 Login(context.Context, *LoginReq) (*UserAuthRes, error) }
UserServer is the server API for User service. All implementations should embed UnimplementedUserServer for forward compatibility.
User 用户管理