Documentation ¶
Overview ¶
Package otp_pb is a reverse proxy.
It translates gRPC into RESTful JSON APIs.
Index ¶
- Variables
- func RegisterOtpGinServer(r gin.IRouter, server OtpServer)
- func RegisterOtpHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error
- func RegisterOtpHandlerClient(ctx context.Context, mux *runtime.ServeMux, client OtpClient) error
- func RegisterOtpHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, ...) (err error)
- func RegisterOtpHandlerServer(ctx context.Context, mux *runtime.ServeMux, server OtpServer) error
- func RegisterOtpServer(s grpc.ServiceRegistrar, srv OtpServer)
- type GenerateRequest
- func (*GenerateRequest) Descriptor() ([]byte, []int)deprecated
- func (x *GenerateRequest) GetExpiry() int64
- func (x *GenerateRequest) GetId() string
- func (x *GenerateRequest) GetSize() int64
- func (*GenerateRequest) ProtoMessage()
- func (x *GenerateRequest) ProtoReflect() protoreflect.Message
- func (x *GenerateRequest) Reset()
- func (x *GenerateRequest) String() string
- func (this *GenerateRequest) Validate() error
- type GenerateResponse
- func (*GenerateResponse) Descriptor() ([]byte, []int)deprecated
- func (x *GenerateResponse) GetCode() string
- func (*GenerateResponse) ProtoMessage()
- func (x *GenerateResponse) ProtoReflect() protoreflect.Message
- func (x *GenerateResponse) Reset()
- func (x *GenerateResponse) String() string
- func (this *GenerateResponse) Validate() error
- type OtpClient
- type OtpServer
- type UnimplementedOtpServer
- type UnsafeOtpServer
- type ValidateRequest
- func (*ValidateRequest) Descriptor() ([]byte, []int)deprecated
- func (x *ValidateRequest) GetCode() string
- func (x *ValidateRequest) GetId() string
- func (*ValidateRequest) ProtoMessage()
- func (x *ValidateRequest) ProtoReflect() protoreflect.Message
- func (x *ValidateRequest) Reset()
- func (x *ValidateRequest) String() string
- func (this *ValidateRequest) Validate() error
- type ValidateResponse
- func (*ValidateResponse) Descriptor() ([]byte, []int)deprecated
- func (x *ValidateResponse) GetSuccess() bool
- func (*ValidateResponse) ProtoMessage()
- func (x *ValidateResponse) ProtoReflect() protoreflect.Message
- func (x *ValidateResponse) Reset()
- func (x *ValidateResponse) String() string
- func (this *ValidateResponse) Validate() error
Constants ¶
This section is empty.
Variables ¶
var File_entry_otp_otp_pb_otp_proto protoreflect.FileDescriptor
Functions ¶
func RegisterOtpGinServer ¶
func RegisterOtpHandler ¶
RegisterOtpHandler registers the http handlers for service Otp to "mux". The handlers forward requests to the grpc endpoint over "conn".
func RegisterOtpHandlerClient ¶
RegisterOtpHandlerClient registers the http handlers for service Otp to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "OtpClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "OtpClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "OtpClient" to call the correct interceptors.
func RegisterOtpHandlerFromEndpoint ¶
func RegisterOtpHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)
RegisterOtpHandlerFromEndpoint is same as RegisterOtpHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterOtpHandlerServer ¶
RegisterOtpHandlerServer registers the http handlers for service Otp to "mux". UnaryRPC :call OtpServer 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 RegisterOtpHandlerFromEndpoint instead.
func RegisterOtpServer ¶
func RegisterOtpServer(s grpc.ServiceRegistrar, srv OtpServer)
Types ¶
type GenerateRequest ¶
type GenerateRequest struct { // unique id, email or user to generate an OTP for Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // number of characters (default: 6) Size int64 `protobuf:"varint,2,opt,name=size,proto3" json:"size,omitempty"` // expiration in seconds (default: 60) Expiry int64 `protobuf:"varint,3,opt,name=expiry,proto3" json:"expiry,omitempty"` // contains filtered or unexported fields }
Generate an OTP (one time pass) code
func (*GenerateRequest) Descriptor
deprecated
func (*GenerateRequest) Descriptor() ([]byte, []int)
Deprecated: Use GenerateRequest.ProtoReflect.Descriptor instead.
func (*GenerateRequest) GetExpiry ¶
func (x *GenerateRequest) GetExpiry() int64
func (*GenerateRequest) GetId ¶
func (x *GenerateRequest) GetId() string
func (*GenerateRequest) GetSize ¶
func (x *GenerateRequest) GetSize() int64
func (*GenerateRequest) ProtoMessage ¶
func (*GenerateRequest) ProtoMessage()
func (*GenerateRequest) ProtoReflect ¶
func (x *GenerateRequest) ProtoReflect() protoreflect.Message
func (*GenerateRequest) Reset ¶
func (x *GenerateRequest) Reset()
func (*GenerateRequest) String ¶
func (x *GenerateRequest) String() string
func (*GenerateRequest) Validate ¶
func (this *GenerateRequest) Validate() error
type GenerateResponse ¶
type GenerateResponse struct { // one time pass code Code string `protobuf:"bytes,1,opt,name=code,proto3" json:"code,omitempty"` // contains filtered or unexported fields }
func (*GenerateResponse) Descriptor
deprecated
func (*GenerateResponse) Descriptor() ([]byte, []int)
Deprecated: Use GenerateResponse.ProtoReflect.Descriptor instead.
func (*GenerateResponse) GetCode ¶
func (x *GenerateResponse) GetCode() string
func (*GenerateResponse) ProtoMessage ¶
func (*GenerateResponse) ProtoMessage()
func (*GenerateResponse) ProtoReflect ¶
func (x *GenerateResponse) ProtoReflect() protoreflect.Message
func (*GenerateResponse) Reset ¶
func (x *GenerateResponse) Reset()
func (*GenerateResponse) String ¶
func (x *GenerateResponse) String() string
func (*GenerateResponse) Validate ¶
func (this *GenerateResponse) Validate() error
type OtpClient ¶
type OtpClient interface { Generate(ctx context.Context, in *GenerateRequest, opts ...grpc.CallOption) (*GenerateResponse, error) Validate(ctx context.Context, in *ValidateRequest, opts ...grpc.CallOption) (*ValidateResponse, error) }
OtpClient is the client API for Otp 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 NewOtpClient ¶
func NewOtpClient(cc grpc.ClientConnInterface) OtpClient
type OtpServer ¶
type OtpServer interface { Generate(context.Context, *GenerateRequest) (*GenerateResponse, error) Validate(context.Context, *ValidateRequest) (*ValidateResponse, error) }
OtpServer is the server API for Otp service. All implementations should embed UnimplementedOtpServer for forward compatibility
type UnimplementedOtpServer ¶
type UnimplementedOtpServer struct { }
UnimplementedOtpServer should be embedded to have forward compatible implementations.
func (UnimplementedOtpServer) Generate ¶
func (UnimplementedOtpServer) Generate(context.Context, *GenerateRequest) (*GenerateResponse, error)
func (UnimplementedOtpServer) Validate ¶
func (UnimplementedOtpServer) Validate(context.Context, *ValidateRequest) (*ValidateResponse, error)
type UnsafeOtpServer ¶
type UnsafeOtpServer interface {
// contains filtered or unexported methods
}
UnsafeOtpServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to OtpServer will result in compilation errors.
type ValidateRequest ¶
type ValidateRequest struct { // unique id, email or user for which the code was generated Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` // one time pass code to validate Code string `protobuf:"bytes,2,opt,name=code,proto3" json:"code,omitempty"` // contains filtered or unexported fields }
Validate the OTP code
func (*ValidateRequest) Descriptor
deprecated
func (*ValidateRequest) Descriptor() ([]byte, []int)
Deprecated: Use ValidateRequest.ProtoReflect.Descriptor instead.
func (*ValidateRequest) GetCode ¶
func (x *ValidateRequest) GetCode() string
func (*ValidateRequest) GetId ¶
func (x *ValidateRequest) GetId() string
func (*ValidateRequest) ProtoMessage ¶
func (*ValidateRequest) ProtoMessage()
func (*ValidateRequest) ProtoReflect ¶
func (x *ValidateRequest) ProtoReflect() protoreflect.Message
func (*ValidateRequest) Reset ¶
func (x *ValidateRequest) Reset()
func (*ValidateRequest) String ¶
func (x *ValidateRequest) String() string
func (*ValidateRequest) Validate ¶
func (this *ValidateRequest) Validate() error
type ValidateResponse ¶
type ValidateResponse struct { // returns true if the code is valid for the ID Success bool `protobuf:"varint,1,opt,name=success,proto3" json:"success,omitempty"` // contains filtered or unexported fields }
func (*ValidateResponse) Descriptor
deprecated
func (*ValidateResponse) Descriptor() ([]byte, []int)
Deprecated: Use ValidateResponse.ProtoReflect.Descriptor instead.
func (*ValidateResponse) GetSuccess ¶
func (x *ValidateResponse) GetSuccess() bool
func (*ValidateResponse) ProtoMessage ¶
func (*ValidateResponse) ProtoMessage()
func (*ValidateResponse) ProtoReflect ¶
func (x *ValidateResponse) ProtoReflect() protoreflect.Message
func (*ValidateResponse) Reset ¶
func (x *ValidateResponse) Reset()
func (*ValidateResponse) String ¶
func (x *ValidateResponse) String() string
func (*ValidateResponse) Validate ¶
func (this *ValidateResponse) Validate() error