Categorygithub.com/gorpher/fastrouter
modulepackage
1.0.0
Repository: https://github.com/gorpher/fastrouter.git
Documentation: pkg.go.dev

# README

FastRouter

FastRouter是一个快速、轻量级的 fasthttp 路由✨。

GoDoc Build Status

目前使用的http路由器大多都是使用tree数据结构实现路由功能。 而且很多路由集成了不必要的功能,导致依赖越亮越臃肿。

路由说明

三种路由:明确路由、前缀路由和变量路由

  1. 明确路由
a.Get("/a", nil)
a.Get("/b", nil)
a.Get("/d", nil) 
  1. 前缀路由
a.PrefixHandler("GET", "/a", nil)
a.PrefixHandler("GET", "/b", nil)
a.PrefixHandler("GET", "/b/:c", nil) 
  1. 变量路由
a.Get( "/:a", nil)
a.Get("/:a/:b", nil)
a.Get( "/:a/:b/", nil)

核心规则:

  1. 明确的路由定义不能重复
  2. 可以定义变量路由和前缀路由的子路由,有限匹配子路由。

中间件

  1. 全局中间件
a := fastrouter.NewRouter()
a.Use(fastrouter.CorsHandler)
  1. 子路由中间件
a.Get("/", func(ctx *fasthttp.RequestCtx) {
    fmt.Fprintln(ctx, "hello world")
},fastrouter.CorsHandler)

# Packages

No description provided by the author

# Functions

BasicAuth is the basic auth handler.
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author

# Type aliases

No description provided by the author