Documentation
¶
Index ¶
- Constants
- Variables
- func JSON(w http.ResponseWriter, data interface{}, code ...int)
- func Md5(b []byte) string
- func ParseInt64(s string) (int64, error)
- func Register(name string, constructor Constructor)
- func RegisterInstance(driverName string, captchaType string, instance Driver)
- func Unregister(name string)
- func UnregisterInstance(driverName string, captchaType string)
- type APIResponse
- type Constructor
- type Data
- type Driver
- type Option
- type OptionSetter
- type Storer
- type Tile
Constants ¶
View Source
const MaxAge = 300 //seconds
Variables ¶
View Source
var ( // verify ErrParameterRequired = errors.New("[captcha]param is empty") ErrIllegalKey = errors.New("[captcha]illegal key") ErrInvalidResponse = errors.New("[captcha]invalid response") // make data ErrGenerateFailed = errors.New("[captcha]generate captcha data failed") ErrBase64EncodeFailed = errors.New("[captcha]encoding base64 data failed") // common ErrUnsupported = errors.New("[captcha]unsupported") // singleon ErrStorerInitFailed = errors.New("[captcha]storer initialization failed") ErrCaptchaInitFailed = errors.New("[captcha]captcha initialization failed") )
Functions ¶
func JSON ¶
func JSON(w http.ResponseWriter, data interface{}, code ...int)
func ParseInt64 ¶
func Register ¶
func Register(name string, constructor Constructor)
func RegisterInstance ¶
func Unregister ¶
func Unregister(name string)
func UnregisterInstance ¶
Types ¶
type APIResponse ¶
type APIResponse struct { Code int `json:"code"` Message string `json:"message"` *Data `json:",omitempty"` }
func (*APIResponse) IsSuccess ¶
func (a *APIResponse) IsSuccess() bool
func (*APIResponse) SetData ¶
func (a *APIResponse) SetData(data *Data) *APIResponse
func (*APIResponse) SetError ¶
func (a *APIResponse) SetError(message string) *APIResponse
func (*APIResponse) SetSuccess ¶
func (a *APIResponse) SetSuccess(message ...string) *APIResponse
type Constructor ¶
type Driver ¶
type Driver interface { Init() error OptionSetter MakeData(ctx context.Context) (*Data, error) Verify(ctx context.Context, key string, response string) error Storer() Storer }
func GetInstanceOk ¶ added in v0.1.0
type Option ¶
type Option func(d OptionSetter)
type OptionSetter ¶
type OptionSetter interface {
SetOption(key string, value interface{})
}
Click to show internal directories.
Click to hide internal directories.