Skip to content

meyskens/go-hcaptcha

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

hCaptcha Go library

This library is a hCaptcha server side library for Go. It allows to verify challange responses sent to the server.

Usage

The library gives a struct set up to verify the challenges of a given private key set up with New(), responses received by the server can be verified with Verify().

import "github.com/meyskens/go-hcaptcha"

func handleRequest(w http.ResponseWriter, r *http.Request) {
    r.ParseForm()
    hcaptchaResponse, _ := r.Form["h-captcha-response"]
    hc := hcaptcha.New("<insert secret key>")
    //Get IP from RemoteAddr
    ip, _, err := net.SplitHostPort(r.RemoteAddr)
    
    resp, err := hc.Verify(hcaptchaResponse[0], ip)
    // handle errors please!
    if resp.Success {
        // captcha OK!
    }
}

About

A Go library for hcaptcha

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages