go-recaptcha: github.com/tekkamanendless/go-recaptcha/recaptchatest Index | Files

package recaptchatest

import "github.com/tekkamanendless/go-recaptcha/recaptchatest"


Package Files


type Server Uses

type Server struct {
    // contains filtered or unexported fields

Server is a test server that can act as a reCAPTCHA stand-in for unit tests.

func NewServer Uses

func NewServer() *Server

NewServer creates a new test server.

func (*Server) Close Uses

func (s *Server) Close()

Close the server.

func (*Server) NewSite Uses

func (s *Server) NewSite() *Site

NewSite creates a new reCAPTCHA site.

func (*Server) VerifyEndpoint Uses

func (s *Server) VerifyEndpoint() string

VerifyEndpoint returns the URL to use for verifying a token.

type Site Uses

type Site struct {
    PublicKey  string // This is the public key.
    PrivateKey string // This is the private key.
    // contains filtered or unexported fields

Site represents a reCAPTCHA site.

func (*Site) GenerateToken Uses

func (s *Site) GenerateToken(tokenData *TokenData) string

GenerateToken generates a new token for the given token data.

func (*Site) NewResponseToken Uses

func (s *Site) NewResponseToken() string

NewResponseToken simulates generating a valid response token.

func (*Site) NewResponseTokenRemoteIP Uses

func (s *Site) NewResponseTokenRemoteIP(remoteIP string) string

NewResponseTokenRemoteIP simulates generating a valid response token for the given remote IP address.

type TokenData Uses

type TokenData struct {
    Used           bool      // Whether or not this token has been used already.
    RemoteIP       string    // (optional) The remote IP address.
    ExpirationDate time.Time // This is when the token expires.

TokenData represents the data for a token.

Package recaptchatest imports 6 packages (graph). Updated 2020-01-24. Refresh now. Tools for package owners. This is a quick bug-fix fork (has fewer than three commits, and only during the week it was created).