Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrCaptchaIncorrect = errors.New("captcha is incorrect") ErrCaptchaExpired = errors.New("captcha is expired") )
Errors
Functions ¶
This section is empty.
Types ¶
type Captcha ¶
type Captcha interface { // ID returns captcha ID. ID() string // Answer returns captcha answer. Answer() string // EncodeToString returns encoded base64 string. EncodeToString() string // HTMLField returns a template.HTML that includes captcha ID hidden input field // and media field(audio/img). HTMLField(fieldName string) template.HTML }
Captcha is an interface that captchas that generated by driver should implements.
type Driver ¶
type Driver interface { // Generate generates a new captcha, returns an error if failed. Generate() (Captcha, error) }
Driver defines how to generate captchas.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is a captchas manager.
func (*Manager) Generate ¶
Generate generates a new captcha and save it to store, returns an error if failed.
type Option ¶
type Option func(*Manager)
Option is a function that receives a pointer of manager.
func CaseSensitive ¶
CaseSensitive is an option that enable or disable case sensitive.
type Store ¶
type Store interface { // Get returns the answer of the given captcha ID, returns // an error if failed. Clear indicates whether delete the // captcha after fetching. Get(ctx context.Context, id string, clear bool) (string, error) // Set saves the captcha ID and answer, returns error // if failed. Set(ctx context.Context, id, answer string) error }
Store defines how to save and load captcha information.
Directories ¶
Path | Synopsis |
---|---|
drivers
module
|
|
stores
|
|
dbstore
Module
|
|
memcachedstore
Module
|
|
memstore
Module
|
|
mysqlstore
Module
|
|
postgresstore
Module
|
|
redisstore
Module
|
|
sqlite3store
Module
|
Click to show internal directories.
Click to hide internal directories.