import pc "github.com/PrivateCaptcha/private-captcha-go"
// Create the client once at startup with your API key.
client, err := pc.NewClient(pc.Configuration{APIKey: "YOUR_API_KEY"})
if err != nil {
log.Fatal(err)
}
// In your form handler, before any business logic:
output, err := client.Verify(r.Context(), pc.VerifyInput{
Solution: r.FormValue("private-captcha-solution"),
Sitekey: "YOUR_SITEKEY",
})
if err != nil {
log.Printf("Captcha verification failed: %v", err)
return
}
if !output.OK() {
log.Printf("Captcha code %d: %s", output.Code, output.Error())
http.Error(w, http.StatusText(http.StatusForbidden), http.StatusForbidden)
return
}
// Verification passed. Process your form submission here.