justcaptcha/internal/captcha/instance.go

34 lines
569 B
Go
Raw Normal View History

package captcha
import (
"image"
"time"
)
var captchaDb CaptchaDB = CaptchaDB{
DB: make(map[ID]ICaptcha)}
func Init(expiry time.Duration) {
captchaDb.SetExpiry(expiry)
}
func New(data string, captcha ICaptcha) (ICaptcha, ID) {
return captchaDb.New(data, captcha)
}
func Image(id ID) (*image.Image, error) {
return captchaDb.Image(id)
}
func Solve(id ID, answer Answer) (bool, error) {
return captchaDb.Solve(id, answer)
}
func IsSolved(id ID) (bool, error) {
return captchaDb.IsSolved(id)
}
func GetExpiry() time.Duration {
return captchaDb.ExpireIn
}