recaptcha: github.com/romanyx/recaptcha Index | Files

package recaptcha

import "github.com/romanyx/recaptcha"

Index

Package Files

client.go response.go

Variables

var (
    // ErrMissingInputSecret when the secret parameter is missing.
    ErrMissingInputSecret = errors.New("missing-input-secret")
    // ErrInvalidInputSecret when the secret parameter is invalid or malformed.
    ErrInvalidInputSecret = errors.New("invalid-input-secret")
    // ErrMissingInputResponse when the response parameter is missing.
    ErrMissingInputResponse = errors.New("missing-input-response")
    // ErrInvalidInputResponse when the response parameter is invalid or malformed.
    ErrInvalidInputResponse = errors.New("invalid-input-response")
    // ErrBadRequest when the request is invalid or malformed.
    ErrBadRequest = errors.New("bad-request")
    // ErrUnsucceeded when response success value equals to false.
    ErrUnsucceeded = errors.New("unsucceeded status")
)

type Client Uses

type Client struct {
    // contains filtered or unexported fields
}

Client struct to verify captcha.

func New Uses

func New(secret string, options ...Option) *Client

New returns initialized Client.

func (*Client) Verify Uses

func (cli *Client) Verify(gRecaptchaResponse string) (*Response, error)

Verify verifies reCaptcha response received from frontend.

func (*Client) VerifyWithIP Uses

func (cli *Client) VerifyWithIP(gRecaptchaResponse, remoteIP string) (*Response, error)

VerifyWithIP verifies reCaptcha response received from frontend with optional remoteip parameter.

type Option Uses

type Option func(*Client)

Option for initializer.

func SetHTTPClient Uses

func SetHTTPClient(httpClient *http.Client) Option

SetHTTPClient sets httpClient. Used in tests for stubing.

func SetTimeout Uses

func SetTimeout(timeout time.Duration) Option

SetTimeout sets timeout for the http client.

type Response Uses

type Response struct {
    Success     bool        `json:"success"`
    ChallengeTs challengeTs `json:"challenge_ts"`
    Hostname    string      `json:"hostname"`
    ErrorCodes  []string    `json:"error-codes"`
}

Response holds data from reCaptcha API response.

Package recaptcha imports 7 packages (graph). Updated 2018-07-25. Refresh now. Tools for package owners.