router

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitRouterSegment

func InitRouterSegment()

InitRouterSegment 初始化链表路由规则

Types

type RouteParse

type RouteParse struct {
	Middleware []middleware.Middleware //中间件 多个 可多次添加 当有一次使用后 清空
	// contains filtered or unexported fields
}

RouteParse 路由解析器

func (*RouteParse) BindFunc

func (r *RouteParse) BindFunc(structFuncName string, f func(*context.Context)) *RouteParse

BindFunc 绑定函数

func (*RouteParse) BindMiddleware

func (r *RouteParse) BindMiddleware(m ...middleware.Middleware) *RouteParse

BindMiddleware 绑定中间件

func (*RouteParse) BindStruct

func (r *RouteParse) BindStruct(strut handleFuncParse.ControllerInstance, aliasName string) *RouteParse

BindStruct 绑定当个struct 可为struct设置别名

func (*RouteParse) BindStructs

func (r *RouteParse) BindStructs(struts ...handleFuncParse.ControllerInstance) *RouteParse

BindStructs 绑定多个struct

func (*RouteParse) MatchFunc

func (r *RouteParse) MatchFunc(newPath, structFuncName string) *RouteParse

MatchFunc 匹配hangdleFuncParse下面已解析完的方法

func (*RouteParse) MatchPrefixToFunc

func (r *RouteParse) MatchPrefixToFunc(structFuncName string) *RouteParse

MatchPrefixToFunc 将包含前缀的路由 全部解析到指定的方法

func (*RouteParse) Prefix

func (r *RouteParse) Prefix(str string) *RouteParse

Prefix 设置路由前缀

type Router

type Router struct {
	Handler    *handleFuncParse.HandleFunc
	Middleware []middleware.Middleware
}

Router 外部通过Router初始化路由规则

type Segment

type Segment struct {
	Name   string //路由单节字符串
	Router *Router
	Parent *Segment
	Child  map[string]*Segment
}

func MatchHandleFunc

func MatchHandleFunc(urlPath string) (*Segment, []string)

MatchHandleFunc 匹配路由查找对应方法

Jump to

Keyboard shortcuts

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