mirror of
https://github.com/astaxie/beego.git
synced 2025-06-19 17:50:39 +00:00
.github
cache
config
context
grace
httplib
logs
migration
orm
plugins
session
swagger
testing
toolbox
utils
captcha
LICENSE
README.md
captcha.go
image.go
image_test.go
siprng.go
siprng_test.go
pagination
testdata
caller.go
caller_test.go
debug.go
debug_test.go
file.go
file_test.go
mail.go
mail_test.go
rand.go
rand_test.go
safemap.go
safemap_test.go
slice.go
slice_test.go
utils.go
validation
.gitignore
.gosimpleignore
.travis.yml
CONTRIBUTING.md
LICENSE
README.md
admin.go
admin_test.go
adminui.go
app.go
beego.go
config.go
config_test.go
controller.go
controller_test.go
doc.go
error.go
error_test.go
filter.go
filter_test.go
flash.go
flash_test.go
hooks.go
log.go
mime.go
namespace.go
namespace_test.go
parser.go
policy.go
router.go
router_test.go
staticfile.go
staticfile_test.go
template.go
template_test.go
templatefunc.go
templatefunc_test.go
tree.go
tree_test.go
unregroute_test.go
Captcha
an example for use captcha
package controllers
import (
"github.com/astaxie/beego"
"github.com/astaxie/beego/cache"
"github.com/astaxie/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>