Documentation ¶
Overview ¶
Package captcha implements generation and verification of image CAPTCHAs. an example for use captcha
``` package controllers
import (
"github.com/ECacheFS/beego" "github.com/ECacheFS/beego/cache" "github.com/ECacheFS/beego/utils/captcha"
)
var cpt *captcha.Captcha
func init() { // use beego cache system store the captcha data store := cache.NewMemoryCache() cpt = captcha.NewWithFilter("/captcha/", store) }
type MainController struct { beego.Controller }
func (this *MainController) Get() { this.TplName = "index.tpl" }
func (this *MainController) Post() { this.TplName = "index.tpl" this.Data["Success"] = cpt.VerifyReq(this.Ctx.Request) }
```
template usage
``` {{.Success}} <form action="/" method="post">
{{create_captcha}} <input name="captcha" type="text">
</form> ```
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Captcha ¶
type Captcha struct { // url prefix for captcha image URLPrefix string // specify captcha id input field name FieldIDName string // specify captcha result input field name FieldCaptchaName string // captcha image width and height StdWidth int StdHeight int // captcha chars nums ChallengeNums int // captcha expiration seconds Expiration time.Duration // cache key prefix CachePrefix string // contains filtered or unexported fields }
Captcha struct
func NewCaptcha ¶
NewCaptcha create a new captcha.Captcha
func NewWithFilter ¶
NewWithFilter create a new captcha.Captcha and auto AddFilter for serve captacha image and add a template func for output html
func (*Captcha) CreateCaptcha ¶
CreateCaptcha create a new captcha id
func (*Captcha) CreateCaptchaHTML ¶ added in v1.6.0
CreateCaptchaHTML template func for output html
Click to show internal directories.
Click to hide internal directories.