Skip to content
This repository has been archived by the owner on Jun 1, 2022. It is now read-only.
/ recaptcha Public archive

Go(lang) Google ReCAPTCHA library. Built for use with the standard http libraries or with Google App Engine.

License

Notifications You must be signed in to change notification settings

chriseaton/recaptcha

Repository files navigation

recaptcha - for go

recaptcha is an easy to use Google ReCaptcha library written in Go, supporting the latest v2 API. It supports simple verification by a single function call, or can be used with Google AppEngine by replacing the http client with AppEngine's urlfetch client.

Report issues here.

Getting Started

In your console:

go get github.com/chriseaton/recaptcha

In your go file:

import "github.com/chriseaton/recaptcha"

Examples

Basic Usage

func pageHandler(w http.ResponseWriter, r *http.Request) {
	res, err := recaptcha.VerifyRequest(r, "{MY_SECRET_HERE}")
	if err != nil {
		fmt.Fprintf(w, "Verify failed: %+v\n", err)
	} else {
		fmt.Fprintf(w, "Verified ok: %+v\n", res)
	}
}

Google AppEngine

func pageHandler(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()
	ctx := appengine.NewContext(r)
	c := &recaptcha.Challenge{
		Secret: "{MY_SECRET_HERE}",
		FormValue: r.FormValue("g-recaptcha-response")
		HttpClient: urlfetch.Client(ctx),
	}
	res, err := recaptcha.Verify(c)
	if err != nil {
		fmt.Fprintf(w, "Verify failed: %+v\n", err)
	} else {
		fmt.Fprintf(w, "Verified ok: %+v\n", res)
	}
}

About

Go(lang) Google ReCAPTCHA library. Built for use with the standard http libraries or with Google App Engine.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages