captcha

package
v0.0.0-...-9713768 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func NewDrive

func NewDrive(cnf *Config) (base64Captcha.Driver, error)

func NewStore

func NewStore(cnf *Config) (*base64Captcha.Store, error)

Types

type Captcha

type Captcha struct {
	*base64Captcha.Captcha
}

func NewCaptcha

func NewCaptcha(driver base64Captcha.Driver, store *base64Captcha.Store) (*Captcha, error)

func (*Captcha) GinHandle

func (ca *Captcha) GinHandle(c *gin.Context)

func (*Captcha) SetStore

func (ca *Captcha) SetStore(s *base64Captcha.Store) error

SetStore .

func (*Captcha) Verify

func (ca *Captcha) Verify(id string, code string) bool

Verify .

type Config

type Config struct {
	// local store default memory store
	// only supports single machine deployment
	// please customize Redis store for multiple servers
	StoreType StoreType
	DriveType DriveType
	// Height Captcha png height in pixel.
	Height int
	// Width Captcha png width in pixel.
	Width int
	// Captcha length
	Length int
}

func NewConfig

func NewConfig() (*Config, error)

type DriveType

type DriveType int
const (
	Digit DriveType = 1 << iota
	String
	Math
	Chinese
	Custom
)

type Response

type Response struct {
	Id   string      `json:"id"`
	Code int         `json:"code"`
	Data interface{} `json:"data"`
	Msg  string      `json:"msg"`
}

Response Gin response format

func (*Response) MakeGinResponse

func (r *Response) MakeGinResponse() gin.H

MakeGinResponse return gin json response object

type StoreType

type StoreType int
const (
	LocalStore StoreType = 1 << iota
	RedisStore
	CustomStore
)

Jump to

Keyboard shortcuts

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