router

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Context

type Context struct {
	RawData []byte // 上下文内容
}

func (*Context) GetBody added in v0.12.9

func (t *Context) GetBody(req any) error

解析 json 内容到 req ,并验证

type Router

type Router[C any] struct {
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter[T any]() *Router[T]

创建路由

func (*Router[C]) GetPerm added in v0.12.10

func (t *Router[C]) GetPerm(name string) (int, error)

获取 controller 需要的权限 @param name 控制器名称 @return 权限,控制器不存在时,error 返回 invalid action

func (*Router[C]) Invoke

func (t *Router[C]) Invoke(name string, ctx *C) (any, error)

触发 controller @param name 控制器名称 @param C 上下文指针 @return controller 结果

func (*Router[C]) On

func (t *Router[C]) On(name string, controller func(*C) (any, error), perm int)

注册路由 @param name 控制器名称 @param controller 处理函数 @param perm 权限,建议使用 1,2,4,8 等方便使用位与的数

Jump to

Keyboard shortcuts

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