Documentation
¶
Overview ¶
Package group 提供了按条件进行分组路由的功能
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HeaderVersion ¶
type HeaderVersion struct {
Versions []string
}
HeaderVersion 匹配报头的版本号
匹配报头 Accept 中的报头信息。
type Hosts ¶
type Hosts struct {
// contains filtered or unexported fields
}
Hosts 限定域名的匹配工具
type Matcher ¶
type Matcher interface {
// Match 验证请求是否符合当前对象的要求
//
// 可能会对参数做出修改,比如通过 context.WithValue 等。
Match(*http.Request) (*http.Request, bool)
}
Matcher 验证一个请求是否符合要求
Matcher 常用于路由项的前置判断,用于对路由项进行归类, 符合同一个 Matcher 的路由项,再各自进行路由。 比如按域名进行分组路由。
type MatcherFunc ¶
MatcherFunc 用于转一个 Match(http.Request) bool 转换成 Matcher 接口
type PathVersion ¶
type PathVersion struct {
// 需要匹配的版本号列表,需要以 / 作分隔,比如 /v3/ /v4/ /v11/
Versions []string
}
PathVersion 匹配路径中的版本号
会修改 *http.Request.URL.Path 的值,去掉匹配的版本号路径部分,比如:
/v1/path.html
如果匹配 v1 版本,会修改为:
/path.html
func NewPathVersion ¶
func NewPathVersion(version ...string) *PathVersion
NewPathVersion 声明 PathVersion 实例
Click to show internal directories.
Click to hide internal directories.