Documentation ¶
Index ¶
- func GetExpiry() time.Duration
- func Image(id captcha.ID, style string) *image.Image
- func IsSolved(id captcha.ID) bool
- func New(data string, captcha captcha.Captcha) (captcha.Captcha, captcha.ID)
- func Remove(id captcha.ID)
- func SetExpiry(expiry time.Duration)
- func Solve(id captcha.ID, answer captcha.Answer) bool
- type InMemoryCaptchaDB
- func (imcdb *InMemoryCaptchaDB) GetExpiry() time.Duration
- func (imcdb *InMemoryCaptchaDB) Image(id captcha.ID, style string) *image.Image
- func (imcdb *InMemoryCaptchaDB) IsSolved(id captcha.ID) bool
- func (imcdb *InMemoryCaptchaDB) New(data string, cptcha captcha.Captcha) (captcha.Captcha, captcha.ID)
- func (imcdb *InMemoryCaptchaDB) Remove(id captcha.ID)
- func (imcdb *InMemoryCaptchaDB) SetExpiry(expiry time.Duration)
- func (imcdb *InMemoryCaptchaDB) Solve(id captcha.ID, answer captcha.Answer) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type InMemoryCaptchaDB ¶
InMemoryCaptchaDB implementation that lives in a memory (map).
func NewInMemoryCaptchaDB ¶
func NewInMemoryCaptchaDB(expiry time.Duration) *InMemoryCaptchaDB
NewInMemoryCaptchaDB returns an initialised instance of an InMemoryCaptchaDB. An expiry is a scan interval for expired CAPTCHAs (if passed a longer one, resets to a default (captcha.DefaultExpiredScanInterval)).
func (*InMemoryCaptchaDB) GetExpiry ¶
func (imcdb *InMemoryCaptchaDB) GetExpiry() time.Duration
GetExpiry returns an expiry for a CAPTCHA.
func (*InMemoryCaptchaDB) Image ¶
Image returns a freshly generated image for a CAPTCHA with style if applicable.
func (*InMemoryCaptchaDB) IsSolved ¶
func (imcdb *InMemoryCaptchaDB) IsSolved(id captcha.ID) bool
IsSolved checks if CAPTCHA was solved and removes it from a database.
func (*InMemoryCaptchaDB) New ¶
func (imcdb *InMemoryCaptchaDB) New(data string, cptcha captcha.Captcha) (captcha.Captcha, captcha.ID)
New accepts a CAPTCHA instance, generates an ID and store it in a database. A data string is an additional random data used to generate an ID, e.g. an IP-address.
func (*InMemoryCaptchaDB) Remove ¶
func (imcdb *InMemoryCaptchaDB) Remove(id captcha.ID)
Remove a CAPTCHA from a database.
func (*InMemoryCaptchaDB) SetExpiry ¶
func (imcdb *InMemoryCaptchaDB) SetExpiry(expiry time.Duration)
SetExpiry changes an expiry for a CAPTCHA and a scan interval. Scan interval cannot be longer than a default, so if it is, then resets to a default.