package main
import (
"log"
"net/http"
pc "github.com/PrivateCaptcha/private-captcha-go"
"github.com/go-chi/chi/v5"
)
func main() {
client, err := pc.NewClient(pc.Configuration{APIKey: "YOUR_API_KEY"})
if err != nil {
log.Fatal(err)
}
router := chi.NewRouter()
router.Post("/submit", func(w http.ResponseWriter, r *http.Request) {
output, err := client.Verify(r.Context(), pc.VerifyInput{
Solution: r.PostFormValue("private-captcha-solution"),
Sitekey: "YOUR_SITEKEY",
})
if err != nil || !output.OK() {
http.Error(w, "Captcha verification failed", http.StatusForbidden)
return
}
// Verification passed. Process your form submission here.
w.Write([]byte("Success!"))
})
log.Fatal(http.ListenAndServe(":8080", router))
}