Documentation
¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func WithContext ¶ added in v0.0.2
WithContext sets the context.Context of a Client
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an hCaptcha client
func New ¶
func New(secret string, options ...ClientOption) (*Client, error)
New returns a new hCaptcha Client
func (*Client) Verify ¶
func (c *Client) Verify(token string, opts PostOptions) (*Response, error)
Verify checks the response against the hCaptcha API
Example ¶
// Dummy secret https://docs.hcaptcha.com/#integrationtest client, err := New(dummySecret) if err != nil { panic(err) } // Dummy token https://docs.hcaptcha.com/#integrationtest resp, err := client.Verify(dummyToken, PostOptions{}) if err != nil { panic(err) } if resp.Success { fmt.Println("Verification succeeded")
Output: Verification succeeded
type ClientOption ¶ added in v0.0.2
type ClientOption func(*Client)
ClientOption is a func to modify a new Client
type ErrorCode ¶
type ErrorCode string
ErrorCode is any possible error from hCaptcha
const ( ErrMissingInputSecret ErrorCode = "missing-input-secret" ErrInvalidInputSecret ErrorCode = "invalid-input-secret" ErrMissingInputResponse ErrorCode = "missing-input-response" ErrInvalidInputResponse ErrorCode = "invalid-input-response" ErrBadRequest ErrorCode = "bad-request" ErrInvalidOrAlreadySeenResponse ErrorCode = "invalid-or-already-seen-response" ErrSitekeySecretMismatch ErrorCode = "sitekey-secret-mismatch" )
type PostOptions ¶
PostOptions are optional post form values