lolly/internal/matcher/matcher.go
xfy ca03c121d3 refactor(matcher): 提取 LocationType 常量并优化结构体字段布局
- 添加 LocationType 常量定义替代硬编码字符串
- 优化 MatchResult、ExactMatcher、NamedMatcher 结构体字段顺序
- RadixTree.Insert 添加 locationType 参数用于调试追踪
- 更新测试代码适配新接口

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-17 10:11:45 +08:00

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
}