func (c *Client) VerifyToken(tkn string) (response Response) {
	if tkn == "" {
		response.ErrorCodes = append(response.ErrorCodes, errors.New("tkn is empty").Error())
		return
	}
	resp, err := c.HTTPClient.PostForm(apiURL,
		url.Values{
			"secret":   {c.secret},
			"response": {tkn},
		},
	)
	if err != nil {
		response.ErrorCodes = append(response.ErrorCodes, err.Error())
		return
	}
	body, err := ioutil.ReadAll(resp.Body)
	resp.Body.Close()
	if err != nil {
		response.ErrorCodes = append(response.ErrorCodes, err.Error())
		return
	}
	err = json.Unmarshal(body, &response)
	if err != nil {
		response.ErrorCodes = append(response.ErrorCodes, err.Error())
		return
	}
	return
}
VerifyToken accepts a token and a secret key (https://dashboard.hcaptcha.com/settings).
It returns the hcaptcha's `Response`.
The `response.Success` reports whether the validation passed.
Any errors are passed through the `response.ErrorCodes` field.
Same as SiteVerify except token is provided by caller instead of being extracted from HTTP request
package hcaptcha
import (
	"context"
	"encoding/json"
	"errors"
	"fmt"
	"io/ioutil"
	"net/http"
	"net/url"
)
var (
	ResponseContextKey interface{} = "hcaptcha"
	DefaultFailureHandler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		http.Error(w, http.StatusText(http.StatusTooManyRequests), http.StatusTooManyRequests)
	})
	PostMaxMemory int64 = 32 << 20
)
type Client struct {
	HTTPClient *http.Client
	FailureHandler http.Handler
	secret string
}
type Response struct {
	ChallengeTS string   `json:"challenge_ts"`
	Hostname    string   `json:"hostname"`
	ErrorCodes  []string `json:"error-codes,omitempty"`
	Success     bool     `json:"success"`
	Credit      bool     `json:"credit,omitempty"`
}
func New(secret string) *Client {
	return &Client{
		HTTPClient:     http.DefaultClient,
		FailureHandler: DefaultFailureHandler,
		secret:         secret,
	}
}
func (c *Client) Handler(next http.Handler) http.Handler {
	return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		v := c.SiteVerify(r)
		r = r.WithContext(context.WithValue(r.Context(), ResponseContextKey, v))
		if v.Success {
			next.ServeHTTP(w, r)
			return
		}
		if c.FailureHandler != nil {
			c.FailureHandler.ServeHTTP(w, r)
		}
	})
}
func (c *Client) HandlerFunc(next func(http.ResponseWriter, *http.Request)) http.HandlerFunc {
	return c.Handler(http.HandlerFunc(next)).ServeHTTP
}
const apiURL = "https://hcaptcha.com/siteverify"
func (c *Client) SiteVerify(r *http.Request) (response Response) {
	generatedResponseID, err := getFormValue(r, "h-captcha-response")
	if err != nil {
		response.ErrorCodes = append(response.ErrorCodes, err.Error())
		return
	}
	if generatedResponseID == "" {
		response.ErrorCodes = append(response.ErrorCodes,
			"form[h-captcha-response] is empty")
		return
	}
	return c.VerifyToken(generatedResponseID)
}