Documentation
¶
Index ¶
- type CaptchaServiceProvider
- type ClickCaptchaResp
- type ClickPoint
- type GenerateReq
- type Options
- type RotateCaptchaResp
- type Service
- func (s *Service) Generate(ctx context.Context, typ string) (interface{}, error)
- func (s *Service) GenerateClick(ctx context.Context, mode string) (*ClickCaptchaResp, error)
- func (s *Service) GenerateRotate(ctx context.Context) (*RotateCaptchaResp, error)
- func (s *Service) GenerateSlide(ctx context.Context, mode string) (*SlideCaptchaResp, error)
- func (s *Service) RegisterRoutes(engine *gin.Engine)
- func (s *Service) Verify(ctx context.Context, req *VerifyReq) (bool, error)
- func (s *Service) VerifyClick(ctx context.Context, req *VerifyClickReq) (bool, error)
- func (s *Service) VerifyRotate(ctx context.Context, req *VerifyRotateReq) (bool, error)
- func (s *Service) VerifySlide(ctx context.Context, req *VerifySlideReq) (bool, error)
- type SlideCaptchaResp
- type VerifyClickReq
- type VerifyReq
- type VerifyRotateReq
- type VerifySlideReq
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CaptchaServiceProvider ¶
type CaptchaServiceProvider struct {
// contains filtered or unexported fields
}
func (*CaptchaServiceProvider) Conf ¶
func (i *CaptchaServiceProvider) Conf() map[string]string
func (*CaptchaServiceProvider) Description ¶
func (i *CaptchaServiceProvider) Description() string
func (*CaptchaServiceProvider) Register ¶
func (i *CaptchaServiceProvider) Register()
Register 注册验证码服务到容器
type ClickCaptchaResp ¶
type ClickPoint ¶
type Options ¶
type Options struct {
Enabled bool `json:"enabled"` // 是否启用
TTL int `json:"ttl"` // 过期时间(秒)
Type string `json:"type"` // 默认验证码类型
Mode string `json:"mode"` // 默认生成模式
Padding int `json:"padding"` // 校验容差
Store string `json:"store"` // 存储驱动(memory|redis)
CleanupInterval int `json:"cleanup-interval"` // 清理间隔(秒)
}
type RotateCaptchaResp ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(opt Options, store cache_captcha.CaptchaStore) (*Service, error)
NewService 创建验证码服务实例
func (*Service) Generate ¶
Generate 生成指定类型的验证码
func (*Service) GenerateClick ¶
GenerateClick 生成点选验证码
func (*Service) GenerateRotate ¶
func (s *Service) GenerateRotate(ctx context.Context) (*RotateCaptchaResp, error)
GenerateRotate 生成旋转验证码
func (*Service) GenerateSlide ¶
GenerateSlide 生成滑块验证码
func (*Service) RegisterRoutes ¶
RegisterRoutes 注册验证码路由
func (*Service) Verify ¶
Verify 校验验证码
func (*Service) VerifyClick ¶
VerifyClick 校验点选验证码
func (*Service) VerifyRotate ¶
VerifyRotate 校验旋转验证码
type SlideCaptchaResp ¶
type VerifyClickReq ¶
type VerifyClickReq struct {
CaptchaId string `json:"captchaId"` // 验证码ID
Points []ClickPoint `json:"points"` // 点选坐标
}
type VerifyReq ¶
type VerifyRotateReq ¶
Source Files
¶
- api.go
- captcha_service_provider.go
- handle.go
- service.go
Click to show internal directories.
Click to hide internal directories.