Documentation
¶
Overview ¶
Package recaptcha handles reCaptcha (http://www.google.com/recaptcha) form submissions
This package is designed to be called from within an HTTP server or web framework which offers reCaptcha form inputs and requires them to be evaluated for correctness
Index ¶
- func DefaultValidateFailedHandler(w http.ResponseWriter, r *http.Request, err error)
- func Interceptor(key interface{}) func(w http.ResponseWriter, r *http.Request) (ok bool, err error)
- func MiddlewareContext(key interface{}, failed ValidationFailedHandler, next http.Handler) http.Handler
- func ValidateContext(key interface{}, w http.ResponseWriter, r *http.Request) (ok bool, err error)
- type ReCaptcha
- func (this *ReCaptcha) Confirm(remoteip, response string) (ok bool, err error)
- func (this *ReCaptcha) FormCheck(w http.ResponseWriter, r *http.Request) (ok bool, err error)
- func (this *ReCaptcha) Middleware(next http.Handler) http.Handler
- func (this *ReCaptcha) ProcessRequest(request *http.Request, realIP string) (result bool, err error)
- func (this *ReCaptcha) Validate(w http.ResponseWriter, r *http.Request) (ok bool, err error)
- type ReCaptchaServerError
- type RecaptchaResponse
- type Site
- type ValidationFailedHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultValidateFailedHandler ¶
func DefaultValidateFailedHandler(w http.ResponseWriter, r *http.Request, err error)
func Interceptor ¶
func MiddlewareContext ¶
func MiddlewareContext(key interface{}, failed ValidationFailedHandler, next http.Handler) http.Handler
func ValidateContext ¶
Types ¶
type ReCaptcha ¶
type ReCaptcha struct {
PrivateKey string
Timeout int8
SkipFunc func(r *http.Request) bool
RealIPFunc func(r *http.Request) string
FailedFunc ValidationFailedHandler
MinScore float32
MaxFormSize int64
Site *Site
Data maps.Map
}
func New ¶
New creates new ReCaptcha object for allows the webserver or code evaluating the reCaptcha form input to set the reCaptcha private key (string) value, which will be different for every domain.
func (*ReCaptcha) Confirm ¶
Confirm is the public interface function. It calls check, which the client ip address, the challenge code from the reCaptcha form, and the client's response input to that challenge to determine whether or not the client answered the reCaptcha input question correctly. It returns a boolean value indicating whether or not the client answered correctly.
func (*ReCaptcha) ProcessRequest ¶
func (this *ReCaptcha) ProcessRequest(request *http.Request, realIP string) (result bool, err error)
ProcessRequest accepts the http.Request object, finds the reCaptcha form variables which were input and sent by HTTP POST to the server, then calls the recaptcha package's Confirm() method, which returns a boolean indicating whether or not the client answered the form correctly.
type ReCaptchaServerError ¶
type ReCaptchaServerError struct {
// contains filtered or unexported fields
}
func (ReCaptchaServerError) Err ¶
func (this ReCaptchaServerError) Err() error
func (ReCaptchaServerError) Error ¶
func (this ReCaptchaServerError) Error() string
type RecaptchaResponse ¶
type Site ¶
type Site struct {
Key string
// contains filtered or unexported fields
}
func (*Site) HeaderScript ¶
func (*Site) HeaderStyle ¶
type ValidationFailedHandler ¶
type ValidationFailedHandler func(w http.ResponseWriter, r *http.Request, err error)