toolkits

package
v0.0.0-...-85b7a69 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2018 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QrcodeLow     = int(qrcode.Low)
	QrcodeMedium  = int(qrcode.Medium)
	QrcodeHigh    = int(qrcode.High)
	QrcodeHighest = int(qrcode.Highest)
)

Variables

This section is empty.

Functions

func GenerateCaptchaID

func GenerateCaptchaID(len int) string

生成二维码的ID,不是实际的验证码数字,参数是验证码的长度

func InitTemplateMiddleware

func InitTemplateMiddleware(manage TemplateManage)

func ServerCaptcha

func ServerCaptcha(c *kelly.Context, width, height int)

request的url必须是 http(s)://host/path/{CaptchaID}.png

func TemplateMiddleware

func TemplateMiddleware(path string) kelly.HandlerFunc

通过中间件预编译模板,并设置到context

func VerifyCaptcha

func VerifyCaptcha(captchaID, captchaCode string) bool

验证验证码

Types

type Qrcode

type Qrcode struct {
	*qrcode.QRCode
}

func NewQRCode

func NewQRCode(content string, level int) (*Qrcode, error)

func (*Qrcode) Image

func (q *Qrcode) Image(size int) image.Image

func (*Qrcode) Write

func (q *Qrcode) Write(size int, out io.Writer) error

func (*Qrcode) WriteFile

func (q *Qrcode) WriteFile(size int, filename string) error

func (*Qrcode) WriteKelly

func (q *Qrcode) WriteKelly(size int, c *kelly.Context) error

type Template

type Template interface {
	// 渲染模板到kelly.Context
	Render(c *kelly.Context, context kelly.H) error
	MustRender(c *kelly.Context, context kelly.H)
}

func CurrentTemplate

func CurrentTemplate(c *kelly.Context) Template

获得当前context的模板

type TemplateManage

type TemplateManage interface {
	// 加载模板
	GetTemplate(string) (Template, error)
	MustGetTemplate(string) Template
}

func NewGoTemplateManage

func NewGoTemplateManage(path string) TemplateManage

创建新的模板管理器

func NewTemplateManage

func NewTemplateManage(path string) TemplateManage

创建新的模板管理器

Jump to

Keyboard shortcuts

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