captcha

package
v0.0.0-...-469a15f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package captcha is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

This section is empty.

Variables

View Source
var Captcha_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "jmash.captcha.Captcha",
	HandlerType: (*CaptchaServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Ping",
			Handler:    _Captcha_Ping_Handler,
		},
		{
			MethodName: "Create",
			Handler:    _Captcha_Create_Handler,
		},
		{
			MethodName: "Validate",
			Handler:    _Captcha_Validate_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "jmash/captcha/service.proto",
}

Captcha_ServiceDesc is the grpc.ServiceDesc for Captcha service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

View Source
var File_jmash_captcha_resources_proto protoreflect.FileDescriptor
View Source
var File_jmash_captcha_service_proto protoreflect.FileDescriptor

Functions

func RegisterCaptchaHandler

func RegisterCaptchaHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterCaptchaHandler registers the http handlers for service Captcha to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterCaptchaHandlerClient

func RegisterCaptchaHandlerClient(ctx context.Context, mux *runtime.ServeMux, client CaptchaClient) error

RegisterCaptchaHandlerClient registers the http handlers for service Captcha to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "CaptchaClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "CaptchaClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "CaptchaClient" to call the correct interceptors.

func RegisterCaptchaHandlerFromEndpoint

func RegisterCaptchaHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterCaptchaHandlerFromEndpoint is same as RegisterCaptchaHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterCaptchaHandlerServer

func RegisterCaptchaHandlerServer(ctx context.Context, mux *runtime.ServeMux, server CaptchaServer) error

RegisterCaptchaHandlerServer registers the http handlers for service Captcha to "mux". UnaryRPC :call CaptchaServer 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 RegisterCaptchaHandlerFromEndpoint instead.

func RegisterCaptchaServer

func RegisterCaptchaServer(s grpc.ServiceRegistrar, srv CaptchaServer)

Types

type CaptchaClient

type CaptchaClient interface {
	// 检查验证码服务是否正常
	Ping(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*wrapperspb.StringValue, error)
	// 获取一个验证码图形挑战
	Create(ctx context.Context, in *emptypb.Empty, opts ...grpc.CallOption) (*Challenge, error)
	// 验证用户输入验证码文本是否正确
	Validate(ctx context.Context, in *CaptchaReq, opts ...grpc.CallOption) (*wrapperspb.BoolValue, error)
}

CaptchaClient is the client API for Captcha 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 NewCaptchaClient

func NewCaptchaClient(cc grpc.ClientConnInterface) CaptchaClient

type CaptchaReq

type CaptchaReq struct {

	// 验证码ID Captcha ID ticket
	CaptchaId string `protobuf:"bytes,1,opt,name=captcha_id,json=captchaId,proto3" json:"captcha_id,omitempty"`
	// 用户输入验证码文本
	CaptchaCode string `protobuf:"bytes,2,opt,name=captcha_code,json=captchaCode,proto3" json:"captcha_code,omitempty"`
	// contains filtered or unexported fields
}

一个用户输入验证码的验证请求

func (*CaptchaReq) Descriptor deprecated

func (*CaptchaReq) Descriptor() ([]byte, []int)

Deprecated: Use CaptchaReq.ProtoReflect.Descriptor instead.

func (*CaptchaReq) GetCaptchaCode

func (x *CaptchaReq) GetCaptchaCode() string

func (*CaptchaReq) GetCaptchaId

func (x *CaptchaReq) GetCaptchaId() string

func (*CaptchaReq) ProtoMessage

func (*CaptchaReq) ProtoMessage()

func (*CaptchaReq) ProtoReflect

func (x *CaptchaReq) ProtoReflect() protoreflect.Message

func (*CaptchaReq) Reset

func (x *CaptchaReq) Reset()

func (*CaptchaReq) String

func (x *CaptchaReq) String() string

type CaptchaServer

type CaptchaServer interface {
	// 检查验证码服务是否正常
	Ping(context.Context, *emptypb.Empty) (*wrapperspb.StringValue, error)
	// 获取一个验证码图形挑战
	Create(context.Context, *emptypb.Empty) (*Challenge, error)
	// 验证用户输入验证码文本是否正确
	Validate(context.Context, *CaptchaReq) (*wrapperspb.BoolValue, error)
	// contains filtered or unexported methods
}

CaptchaServer is the server API for Captcha service. All implementations must embed UnimplementedCaptchaServer for forward compatibility

type Challenge

type Challenge struct {

	// 验证码ID Captcha ID ticket
	CaptchaId string `protobuf:"bytes,1,opt,name=captcha_id,json=captchaId,proto3" json:"captcha_id,omitempty"`
	// 验证码提出的问题 captcha question
	Question string `protobuf:"bytes,2,opt,name=question,proto3" json:"question,omitempty"`
	// Base64编码的验证码图形 Captcha Image Base64
	Base64Image string `protobuf:"bytes,3,opt,name=base64_image,json=base64Image,proto3" json:"base64_image,omitempty"`
	// contains filtered or unexported fields
}

一个验证码图形挑战 Captcha Challenge

func (*Challenge) Descriptor deprecated

func (*Challenge) Descriptor() ([]byte, []int)

Deprecated: Use Challenge.ProtoReflect.Descriptor instead.

func (*Challenge) GetBase64Image

func (x *Challenge) GetBase64Image() string

func (*Challenge) GetCaptchaId

func (x *Challenge) GetCaptchaId() string

func (*Challenge) GetQuestion

func (x *Challenge) GetQuestion() string

func (*Challenge) ProtoMessage

func (*Challenge) ProtoMessage()

func (*Challenge) ProtoReflect

func (x *Challenge) ProtoReflect() protoreflect.Message

func (*Challenge) Reset

func (x *Challenge) Reset()

func (*Challenge) String

func (x *Challenge) String() string

type UnimplementedCaptchaServer

type UnimplementedCaptchaServer struct {
}

UnimplementedCaptchaServer must be embedded to have forward compatible implementations.

func (UnimplementedCaptchaServer) Create

func (UnimplementedCaptchaServer) Ping

func (UnimplementedCaptchaServer) Validate

type UnsafeCaptchaServer

type UnsafeCaptchaServer interface {
	// contains filtered or unexported methods
}

UnsafeCaptchaServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to CaptchaServer will result in compilation errors.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL