Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GoCaptcha ¶
type GoCaptcha struct {
// contains filtered or unexported fields
}
A GoCaptcha object identifies a single reCAPTCHA session (for one client). It is possible to store this object on a session activity and re-use it lateron for verification. This object keeps track of faulty verifications and makes sure any newly generated HTML contains an error message for the end-user, as provided by reCAPTCHA. Once a reCAPTCHA response was successfully verified this object should be discarded.
func NewGoCaptcha ¶
NewGoCaptha creates a new GoCaptcha object. Privatekey is the api key to be used with reCAPTCHA.
func (*GoCaptcha) HTMLBytes ¶
Generate the reCAPTCHA HTML for this session and return it as byteslice. If error is not nil then something went wrong and the byteslice is empty.
func (*GoCaptcha) HTMLString ¶
Generate the reCAPTCHA HTML for this session and return it as string. If error is not nil then something went wrong and string is empty.
func (*GoCaptcha) Verify ¶
Verify calls the reCAPTCHA API to verify if the given response by end-user is correct. Any returned error indicates a unsuccessfull api call. It does not indicate that the reCAPTCHA response by the end-user was faulty. Any returned error value is not to be shown to the end-user. When the error is nil, then response=false indicates that the reCAPTCHA response by the end-user was faulty. End-user will be notified of a faulty reCAPTCHA response when re-using this GoCaptcha object to generate HTML code again.
Expected parameters: challenge string, form value as sent by the http request. (Set by the reCAPTCHA in the end-users browser.) response string, form value as sent by the http request. (The answer given by the end-user.) remoteaddr string, The http.Request.RemoteAddr (e.g. "127.0.0.1:45435") from the client's endpoint.