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 InMemoryDB
- func (imcdb *InMemoryDB) GetExpiry() time.Duration
- func (imcdb *InMemoryDB) Image(id captcha.ID, style string) *image.Image
- func (imcdb *InMemoryDB) IsSolved(id captcha.ID) bool
- func (imcdb *InMemoryDB) New(data string, cptcha captcha.Captcha) (captcha.Captcha, captcha.ID)
- func (imcdb *InMemoryDB) Remove(id captcha.ID)
- func (imcdb *InMemoryDB) SetExpiry(expiry time.Duration)
- func (imcdb *InMemoryDB) Solve(id captcha.ID, answer captcha.Answer) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type InMemoryDB ¶
InMemoryDB implementation that lives in a memory (map).
func NewInMemoryDB ¶
func NewInMemoryDB(expiry time.Duration) *InMemoryDB
NewInMemoryDB returns an initialised instance of an InMemoryDB. An expiry is a scan interval for expired CAPTCHAs (if passed a longer one, resets to a default (captcha.DefaultExpiredScanInterval)).
func (*InMemoryDB) GetExpiry ¶
func (imcdb *InMemoryDB) GetExpiry() time.Duration
GetExpiry returns an expiry for a CAPTCHA.
func (*InMemoryDB) Image ¶
Image returns a freshly generated image for a CAPTCHA with style if applicable.
func (*InMemoryDB) IsSolved ¶
func (imcdb *InMemoryDB) IsSolved(id captcha.ID) bool
IsSolved checks if CAPTCHA was solved and removes it from a database.
func (*InMemoryDB) New ¶
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 (*InMemoryDB) Remove ¶
func (imcdb *InMemoryDB) Remove(id captcha.ID)
Remove a CAPTCHA from a database.
func (*InMemoryDB) SetExpiry ¶
func (imcdb *InMemoryDB) 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.