captchahttp

package
v0.4.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package captchahttp protects HTTP endpoints with CAPTCHA verification. Package captchahttp 为 HTTP 端点提供 CAPTCHA 验证。

Index

Constants

View Source
const TokenHeader = "X-Captcha-Token"

TokenHeader carries the token returned by the browser widget. TokenHeader 携带浏览器组件返回的 token。

Variables

This section is empty.

Functions

func New

func New(opts Options) (func(http.Handler) http.Handler, error)

New returns nil when disabled. When enabled, a missing Verify is an error. The middleware reads TokenHeader without consuming the request body. New 在关闭时返回 nil。启用但缺少 Verify 时返回错误。 中间件读取 TokenHeader,不消费请求体。

Types

type Options

type Options struct {
	// Enabled defaults to false; disabled protection never calls Verify.
	// Enabled 默认关闭;关闭时不会调用 Verify。
	Enabled bool
	// Verify must be non-nil when enabled, safe for concurrent calls, and return
	// nil only on success. Use a captcha.Client's Verify method or a custom verifier.
	// 启用时 Verify 不能为 nil,必须支持并发调用,且仅在成功时返回 nil。
	// 可传入 captcha.Client 的 Verify 方法或自定义验证函数。
	Verify func(context.Context, string) error
}

Options enables verification using an application-supplied function. Options 通过应用提供的函数启用验证。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL