xrouter

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PTYPE_DIY      = 0 // 自定义校验
	PTYPE_USERNAME = 1 // 账号校验
	PTYPE_PASSWORD = 2 // 密码校验
	PTYPE_INT      = 3 // 整数校验
	PTYPE_UINT     = 4 // 正整数校验
	PTYPE_NUMBERS  = 5 // 数字列表 1,2,3
	PTYPE_ID       = 6 // ID校验
)

Variables

View Source
var RouterPools = make(map[string]*XRouter) // 路由函数

Functions

func Register

func Register(router XRouter)

Types

type Param

type Param struct {
	Title   string // 标题
	Key     string // 参数的名字
	Comment string // 参数备注  生成API用到
	Type    int    // 参数类型
	Default string // 默认值
	Require bool   // 是否是必填
	Func    func(value string) bool
}

* 参数自动校验

func (Param) Check

func (this Param) Check(value string) bool

参数校验

type XRouter

type XRouter struct {
	Title     string                                                     // 路由的名字
	Router    string                                                     // 路由
	Callback  func(xparam *xparam.XParam, auth *xauth.XAuth) xresp.XResp // 回调函数
	Method    string
	IsLogin   bool    // 是否验证登录
	Params    []Param // 自动校验参数列表, 不校验也可以拿到其他的参数. 这里主要是为了校验其他数据格式
	MaxMemory int64
}

func Get

func Get(method, path string) *XRouter

根据正则匹配,检测出符合的一个路由

Jump to

Keyboard shortcuts

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