Captcha

Middleware captcha provides captcha service for Macaron Instances.

Installation

go get github.com/go-macaron/captcha

Usage

To use this middleware, you have to register cache first.

// main.go
import (
    "github.com/go-macaron/cache"
    "github.com/go-macaron/captcha"
    "gopkg.in/macaron.v1"
)

func main() {
    m := macaron.Classic()
    m.Use(cache.Cacher())
    m.Use(captcha.Captchaer())

    m.Get("/", func(ctx *macaron.Context, cpt *captcha.Captcha) string {
        if cpt.VerifyReq(ctx.Req) {
            return "valid captcha"
        }
        return "invalid captcha"
    })

    m.Run()
}

Options

captcha.Captchaer comes with a variety of configuration options:

Last updated

Was this helpful?