Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Multistage ¶
type Multistage[HandleFunc any] struct { // contains filtered or unexported fields }
Multistage 支持多级分类的路由器
func NewMultistage ¶
func NewMultistage[HandleFunc any](options ...MultistageOption[HandleFunc]) *Multistage[HandleFunc]
NewMultistage 创建一个支持多级分类的路由器
func (*Multistage[HandleFunc]) Match ¶
func (r *Multistage[HandleFunc]) Match(routes ...any) HandleFunc
Match 匹配已绑定处理函数的路由,返回处理函数
- 如果未找到将会返回空指针
func (*Multistage[HandleFunc]) Register ¶
func (r *Multistage[HandleFunc]) Register(routes ...any) MultistageBind[HandleFunc]
Register 注册路由是结合 Sub 和 Route 的快捷方式,用于一次性注册多级路由
- 该函数将返回一个注册函数,可通过调用其将路由绑定到特定处理函数,例如:router.Register("a", "b").Bind(onExec())
func (*Multistage[HandleFunc]) Route ¶
func (r *Multistage[HandleFunc]) Route(route any, handleFunc HandleFunc)
Route 为特定路由绑定处理函数,被绑定的处理函数将可以通过 Match 函数进行匹配
func (*Multistage[HandleFunc]) Sub ¶
func (r *Multistage[HandleFunc]) Sub(route any) *Multistage[HandleFunc]
Sub 获取子路由器
type MultistageBind ¶
type MultistageBind[HandleFunc any] func(HandleFunc)
MultistageBind 多级分类路由绑定函数
func (MultistageBind[HandleFunc]) Bind ¶
func (slf MultistageBind[HandleFunc]) Bind(handleFunc HandleFunc)
Bind 将处理函数绑定到预设的路由中
type MultistageOption ¶
type MultistageOption[HandleFunc any] func(multistage *Multistage[HandleFunc])
MultistageOption 路由器选项
func WithRouteTrim ¶
func WithRouteTrim[HandleFunc any](handle func(route any) any) MultistageOption[HandleFunc]
WithRouteTrim 路由修剪选项
- 将在路由注册前对路由进行对应处理
Click to show internal directories.
Click to hide internal directories.