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: 4 Imported by: 1

README

自定义路由处理器 准备移除

调用方式:
    1. router.AddCompile(`auth/(\w+)`, "auth/$1")
    2. router.AddCompile(`auth/(\w+)`, "auth/$1", []middleware.Middleware{ //绑定中间件
    	    &middleware.CorsMiddle{},
         }...)
    3. router.AddCompileGroup("checkLogin", map[string]string{ //按路由分组 绑定中间件
            `sysApi/(\w+)`: "sysApi/$1",
            `admin/(\w+)`:  "admin/$1",
        }, []middleware.Middleware{
            &middleware.CorsMiddle{},
            &middleware.LMiddle{},
        })

注意:
    如果使用了自定义路由,最好也同时接管掉其他路由,这样可以避免自定义路由和默认路由同时存在
        // 过滤其他路由
        router.AddCompile(`\w.*`, "welcome/index")

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCompile

func AddCompile(key, value string, middle ...middleware.Middleware)

AddCompile 设置路由规则

func AddCompileGroup

func AddCompileGroup(name string, rules map[string]string, middle []middleware.Middleware)

AddCompileGroup 设置路由分组规则,用来适配局部中间件调用

func ParseUrlPath

func ParseUrlPath(urlPath string) (string, string, []string, []middleware.Middleware)

ParseUrlPath 解析请求地址 返回cName[struct名称或别名] method[方法名] []参数

Types

type Router

type Router struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

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