- 添加 LocationType 常量定义替代硬编码字符串 - 优化 MatchResult、ExactMatcher、NamedMatcher 结构体字段顺序 - RadixTree.Insert 添加 locationType 参数用于调试追踪 - 更新测试代码适配新接口 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
29 lines
642 B
Go
29 lines
642 B
Go
package matcher
|
|
|
|
import "github.com/valyala/fasthttp"
|
|
|
|
// LocationType 常量定义
|
|
const (
|
|
LocationTypeExact = "exact"
|
|
LocationTypePrefix = "prefix"
|
|
LocationTypePrefixPriority = "prefix_priority"
|
|
LocationTypeRegex = "regex"
|
|
LocationTypeRegexCaseless = "regex_caseless"
|
|
LocationTypeNamed = "named"
|
|
)
|
|
|
|
// MatchResult 匹配结果
|
|
type MatchResult struct {
|
|
Captures map[string]string // 正则捕获组
|
|
Handler fasthttp.RequestHandler
|
|
LocationType string
|
|
Path string
|
|
Priority int
|
|
}
|
|
|
|
// Matcher 接口
|
|
type Matcher interface {
|
|
Match(path string) bool
|
|
Result() *MatchResult
|
|
}
|