Documentation
¶
Overview ¶
Package types 类型的前置声明
Index ¶
- Variables
- type BuildNodeHandleOf
- type Context
- func (ctx *Context) Bool(key string) (bool, error)
- func (ctx *Context) Count() (cnt int)
- func (ctx *Context) Delete(k string)
- func (ctx *Context) Destroy()
- func (ctx *Context) Exists(key string) bool
- func (ctx *Context) Float(key string) (float64, error)
- func (ctx *Context) Get(key string) (string, bool)
- func (ctx *Context) Int(key string) (int64, error)
- func (ctx *Context) MustBool(key string, def bool) bool
- func (ctx *Context) MustFloat(key string, def float64) float64
- func (ctx *Context) MustInt(key string, def int64) int64
- func (ctx *Context) MustString(key, def string) string
- func (ctx *Context) MustUint(key string, def uint64) uint64
- func (ctx *Context) Node() Node
- func (ctx *Context) Params() Params
- func (ctx *Context) Range(f func(key, val string))
- func (ctx *Context) Reset()
- func (ctx *Context) RouterName() string
- func (ctx *Context) Set(k, v string)
- func (ctx *Context) SetNode(n Node)
- func (ctx *Context) SetRouterName(n string)
- func (ctx *Context) String(key string) (string, error)
- func (ctx *Context) Uint(key string) (uint64, error)
- type MiddlewareFuncOf
- type MiddlewareOf
- type Node
- type Params
- type Route
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrParamNotExists = errors.New("不存在该参数")
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
Path string // 实际请求的路径信息
// contains filtered or unexported fields
}
Context 保存着路由匹配过程中的上下文关系
Context 同时实现了 Route 接口。
func NewContext ¶
func NewContext() *Context
func (*Context) MustString ¶
func (*Context) RouterName ¶
func (*Context) SetRouterName ¶
type MiddlewareFuncOf ¶
type MiddlewareFuncOf[T any] func(T) T
MiddlewareFuncOf 中间件处理函数
func (MiddlewareFuncOf[T]) Middleware ¶
func (f MiddlewareFuncOf[T]) Middleware(next T) T
type MiddlewareOf ¶
type MiddlewareOf[T any] interface { Middleware(T) T }
MiddlewareOf 中间件对象需要实现的接口
type Node ¶
type Node interface {
// Pattern 路由上的匹配内容
Pattern() string
// Methods 当前节点支持的方法列表
Methods() []string
// AllowHeader Allow 报头的内容
AllowHeader() string
}
Node 路由节点
type Params ¶
type Params interface {
// Count 返回参数的数量
Count() int
// Get 获取指定名称的参数值
Get(key string) (v string, found bool)
// Exists 查找指定名称的参数是否存在
Exists(key string) bool
// String 获取地址参数中的名为 key 的变量并将其转换成 string
//
// 当参数不存在时,返回 [ErrParamNotExists] 错误。
String(key string) (string, error)
// MustString 获取地址参数中的名为 key 的变量并将其转换成 string
//
// 若不存在或是无法转换则返回 def。
MustString(key, def string) string
// Int 获取地址参数中的名为 key 的变量并将其转换成 int64
//
// 当参数不存在时,返回 [ErrParamNotExists] 错误。
Int(key string) (int64, error)
// MustInt 获取地址参数中的名为 key 的变量并将其转换成 int64
//
// 若不存在或是无法转换则返回 def。
MustInt(key string, def int64) int64
// Uint 获取地址参数中的名为 key 的变量并将其转换成 uint64
//
// 当参数不存在时,返回 [ErrParamNotExists] 错误。
Uint(key string) (uint64, error)
// MustUint 获取地址参数中的名为 key 的变量并将其转换成 uint64
//
// 若不存在或是无法转换则返回 def。
MustUint(key string, def uint64) uint64
// Bool 获取地址参数中的名为 key 的变量并将其转换成 bool
//
// 当参数不存在时,返回 [ErrParamNotExists] 错误。
Bool(key string) (bool, error)
// MustBool 获取地址参数中的名为 key 的变量并将其转换成 bool
//
// 若不存在或是无法转换则返回 def。
MustBool(key string, def bool) bool
// Float 获取地址参数中的名为 key 的变量并将其转换成 Float64
//
// 当参数不存在时,返回 [ErrParamNotExists] 错误。
Float(key string) (float64, error)
// MustFloat 获取地址参数中的名为 key 的变量并将其转换成 float64
//
// 若不存在或是无法转换则返回 def。
MustFloat(key string, def float64) float64
// Set 添加或是修改值
Set(key, val string)
// Range 依次访问每个参数
Range(func(key, val string))
}
Params 表示路由中的参数操作接口
Click to show internal directories.
Click to hide internal directories.