Documentation ¶
Index ¶
- Variables
- func SessionIDFromContext(ctx context.Context) string
- func WithSessionID(ctx context.Context, gen IDGenerator) context.Context
- type CaptchaResolveEngine
- type CaptchaResolver
- type CaptchaResult
- type CaptchaSession
- type EngineOption
- type IDGenerator
- type NoopIDGen
- type Option
- type Preprocessor
- type ResultReporter
- type StatsCaptchaResolver
- func (s *StatsCaptchaResolver) Report(ctx context.Context, captcha *CaptchaResult, correct bool) error
- func (s *StatsCaptchaResolver) ResolveFile(ctx context.Context, r io.Reader) (*CaptchaResult, error)
- func (s *StatsCaptchaResolver) ResolveImage(ctx context.Context, img image.Image) (*CaptchaResult, error)
- type StatsPreprocessor
- type StatsSymbolResolver
- type SymbolResolver
Constants ¶
This section is empty.
Variables ¶
View Source
var (
ErrCaptchaInvalid = errors.New("captcha is invalid")
)
View Source
var (
ErrLimitExceeded = errors.New("session: retry limit exceeded")
)
Functions ¶
func SessionIDFromContext ¶
func WithSessionID ¶
func WithSessionID(ctx context.Context, gen IDGenerator) context.Context
Types ¶
type CaptchaResolveEngine ¶
type CaptchaResolveEngine struct {
// contains filtered or unexported fields
}
func NewCaptchaResolveEngine ¶
func NewCaptchaResolveEngine(opts ...Option) (*CaptchaResolveEngine, error)
func (*CaptchaResolveEngine) ResolveFile ¶
func (e *CaptchaResolveEngine) ResolveFile(ctx context.Context, r io.Reader) (*CaptchaResult, error)
func (*CaptchaResolveEngine) ResolveImage ¶
func (e *CaptchaResolveEngine) ResolveImage(ctx context.Context, img image.Image) (*CaptchaResult, error)
type CaptchaResolver ¶
type CaptchaResult ¶
type CaptchaResult struct {
Captcha string `json:"captcha"`
}
type CaptchaSession ¶
type CaptchaSession struct { CaptchaURL string Engine CaptchaResolver IDGenerator IDGenerator RetryCount int Transport http.RoundTripper }
func NewCaptchaSession ¶
func NewCaptchaSession(captchaURL string, eng CaptchaResolver) *CaptchaSession
type EngineOption ¶
type EngineOption struct {
// contains filtered or unexported fields
}
type IDGenerator ¶
type IDGenerator interface {
NewID() string
}
type Option ¶
type Option func(*EngineOption) error
func WithBinaryWidth ¶
func WithCaptchaLength ¶
func WithPreprocessor ¶
func WithPreprocessor(preprocessor Preprocessor) Option
func WithSymbolResolver ¶
func WithSymbolResolver(sr SymbolResolver) Option
type Preprocessor ¶
type ResultReporter ¶
type ResultReporter interface {
Report(ctx context.Context, result *CaptchaResult, correct bool) error
}
type StatsCaptchaResolver ¶
type StatsCaptchaResolver struct {
CaptchaResolver
}
func (*StatsCaptchaResolver) Report ¶
func (s *StatsCaptchaResolver) Report(ctx context.Context, captcha *CaptchaResult, correct bool) error
func (*StatsCaptchaResolver) ResolveFile ¶
func (s *StatsCaptchaResolver) ResolveFile(ctx context.Context, r io.Reader) (*CaptchaResult, error)
func (*StatsCaptchaResolver) ResolveImage ¶
func (s *StatsCaptchaResolver) ResolveImage(ctx context.Context, img image.Image) (*CaptchaResult, error)
type StatsPreprocessor ¶
type StatsPreprocessor struct {
Preprocessor
}
func (*StatsPreprocessor) Preprocess ¶
type StatsSymbolResolver ¶
type StatsSymbolResolver struct {
SymbolResolver
}
func (*StatsSymbolResolver) SymbolResolve ¶
Click to show internal directories.
Click to hide internal directories.