Documentation
¶
Index ¶
- func NewMathGenerator(config frameCaptcha.MathConfig) frameCaptcha.Generator
- func NewRedisRateLimiter(client *redis.Client, config *frameCaptcha.Config) frameCaptcha.RateLimiter
- func NewRedisStore(client *redis.Client) frameCaptcha.Store
- func NewService(store frameCaptcha.Store, generator frameCaptcha.Generator, ...) frameCaptcha.Service
- type MathGenerator
- type RedisRateLimiter
- func (r *RedisRateLimiter) AllowGenerate(ctx context.Context, identifier string) error
- func (r *RedisRateLimiter) AllowVerify(ctx context.Context, identifier string) error
- func (r *RedisRateLimiter) RecordFailure(ctx context.Context, identifier string) error
- func (r *RedisRateLimiter) Reset(ctx context.Context, identifier string) error
- type RedisStore
- func (s *RedisStore) Delete(ctx context.Context, id string) error
- func (s *RedisStore) Exists(ctx context.Context, id string) (bool, error)
- func (s *RedisStore) Get(ctx context.Context, id string) (string, error)
- func (s *RedisStore) Save(ctx context.Context, id string, answer string, ttl time.Duration) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMathGenerator ¶
func NewMathGenerator(config frameCaptcha.MathConfig) frameCaptcha.Generator
NewMathGenerator 创建数学验证码生成器
func NewRedisRateLimiter ¶
func NewRedisRateLimiter(client *redis.Client, config *frameCaptcha.Config) frameCaptcha.RateLimiter
NewRedisRateLimiter 创建 Redis 限流器
func NewRedisStore ¶
func NewRedisStore(client *redis.Client) frameCaptcha.Store
NewRedisStore 创建 Redis 存储
func NewService ¶
func NewService( store frameCaptcha.Store, generator frameCaptcha.Generator, rateLimiter frameCaptcha.RateLimiter, config *frameCaptcha.Config, ) frameCaptcha.Service
NewService 创建验证码服务
Types ¶
type MathGenerator ¶
type MathGenerator struct {
// contains filtered or unexported fields
}
MathGenerator 数学验证码生成器
func (*MathGenerator) Generate ¶
func (g *MathGenerator) Generate(ctx context.Context, captchaType frameCaptcha.CaptchaType) (*frameCaptcha.CaptchaData, string, error)
type RedisRateLimiter ¶
type RedisRateLimiter struct {
// contains filtered or unexported fields
}
RedisRateLimiter Redis 限流器
func (*RedisRateLimiter) AllowGenerate ¶
func (r *RedisRateLimiter) AllowGenerate(ctx context.Context, identifier string) error
func (*RedisRateLimiter) AllowVerify ¶
func (r *RedisRateLimiter) AllowVerify(ctx context.Context, identifier string) error
func (*RedisRateLimiter) RecordFailure ¶
func (r *RedisRateLimiter) RecordFailure(ctx context.Context, identifier string) error
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore Redis 存储实现
Click to show internal directories.
Click to hide internal directories.