Documentation ¶
Index ¶
Constants ¶
View Source
const Endpoint = "https://google.com/recaptcha/api/siteverify"
Endpoint to reCAPTCHA API.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client wraps around a fasthttp.Client for verifying reCAPTCHA requests.
func (*Client) Do ¶
Do verifies a reCAPTCHA v2 or v3 attempt against reCAPTCHA's API. It errors if an error occurred pinging Google's servers, or on validating the response from Google's servers.
type Request ¶
type Request struct { // Required. The shared key between your site and reCAPTCHA. Secret string // Required. The user response token provided by the reCAPTCHA client-side integration on your site. Response string // Optional. The user's IP address. RemoteIP string }
Request holds the payload to be sent to reCAPTCHA's API.
type Response ¶
type Response struct { // Whether this request was a valid reCAPTCHA token for your site. Success bool `json:"success"` // (v3) The score for this request (0.0 - 1.0). 0.0 signifies high likelihood of a bot, and 1.0 signifies // otherwise. Score float64 `json:"score"` // (v3) The action name for this request (important to verify). Action string `json:"action"` // Timestamp of the challenge load (ISO format yyyy-MM-dd'T'HH:mm:ssZZ). ChallengeTS time.Time `json:"challenge_ts"` // The hostname of the site, or package name of the Android APK where the reCAPTCHA was solved. Hostname string `json:"hostname"` // Optional error codes. ErrorCodes []string `json:"error-codes"` }
Response represents a response from reCAPTCHA's API.
func Do ¶
Do verifies a reCAPTCHA v2 or v3 attempt against reCAPTCHA's API. It errors if an error occurred pinging Google's servers, or on validating the response from Google's servers.
Click to show internal directories.
Click to hide internal directories.